Set Fixed Heap Size in Tomcat

30 minutes
  • 4 Learning Objectives

About this Hands-on Lab

Welcome to this hands-on lab, where we will set Tomcat to use a fixed heap size. This is so that the memory is pre allocated.

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 for you on port **8080**, on the provided server.

Once the heap size is set, you should be able to see the changes on the Tomcat Manager GUI page.

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 to 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 paste it in your browser, then append :8080 to it.

For example, if the 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 server’s GUI on port 8080.

Go to the Tomcat GUI and Check the JVM Memory Settings

Go to the Tomcat GUI and check the server status page. You should take note of the memory settings that are originally applied to the Tomcat instance.

Change Your Tomcat Server so It Has a Minimum and Maximum Heap Size of 1gb

The options to add to the Tomcat startup file (you may need to create the file) are these:

-Xms1g 
-Xmx1g

This should be set in a file under the bin folder called setenv.sh.

These entries should be exported as CATALINA_OPTS.

Restart the Tomcat Server and Check the JVM Memory

Go to the Tomcat Manager GUI, then to the Server Status application and check the JVM memory.

It should reflect the changes you made to the minimum and maximum settings, and be much higher than the original settings.

Additional Resources

Instructions

It has been noted that Tomcat performs better in production environments when you have a fixed heap size set.

You have been tasked with adjusting the heap size on your Tomcat server so that it uses the following heap size settings:

  • Initial heap size = 1gb
  • Maximum heap size = 1gb

You will need to create a bin/setenv.sh file and add the minimum and maximum settings there. You will need to restart the Tomcat server and check the settings on the Tomcat Manager GUI via the server status page.

Note: It may take 3 to 10 minutes after the hands-on lab has started before you are able to log into the server. This is fine and will not affect the performance of the tasks for the hands-on lab.

Logging In

Use the credentials provided on the hands-on lab page, and log in to the provided server as cloud_user. Note that the credentials work for connecting to both the server and the Tomcat GUI.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Get Started
Who’s going to be learning?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


$2,495.00

Checkout
Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!