Welcome to this hands-on lab, where we will set Tomcat up to use verbose garbage collection. As part of this lab you will also enable parallel garbage collection.
It is useful to have verbose garbage collection set, to help you troubleshoot your Tomcat instance and its applications.
We are using Apache’s Tomcat, a Java-based application platform built around deploying and managing Java Web Applications. The server provided in this lab environment is running Red Hat Enterprise 8 and has Tomcat 9 pre-installed for you. The Tomcat instance is available on port **8080**.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Test to Ensure You Can Access the Preconfigured Tomcat Instances on Port 8080
Use the Tomcat server’s public IP address and port 8080. Connect to the Tomcat GUI and log in. The username and password to use are the same as what’s provided for CLI access.
To access the server, copy the external IP address and test in your browser by using this IP address and appending the :8080 to it.
For example, if an IP address shown was 3.92.152.3, then you would put the following into your web browser:
http://3.92.152.3:8080
You should see the GUI.
Note: It may take from 3 to 10 mins after the Hands-On Lab has started before you can access the Tomcat servers on Port 8080.
- Configure Tomcat to Use Verbose and Parallel Garbage Collection
You will need to set options for Tomcat’s startup routine so that it uses verbose and parallel garbage collection.
The options to add to the Tomcat startup file (you may need to create the file) are the following:
- Verbose garbage collection:
-verbose:gc
- Parallel Garbage collection:
-XX:-UseParallelGC
These entries should be exported as
CATALINA_OPTS
.- Verbose garbage collection:
- Restart Tomcat and Monitor the Logs for GC Messages
Restart the Tomcat server.
Check the Tomcat logs for entries relating to garbage collection. The log to look into is the
catalina.out
log.An example verbose log entry might look like the following:
[2.536s][info][gc] GC(0) Pause Young (Allocation Failure) 66M->7M(1015M) 22.821ms