Never accept the defaults: Lessons Learned using OpenJ9 in a Container

Never accept the defaults: Lessons Learned using OpenJ9 in a Container

Eclipse OpenJ9 is an efficient virtual machine with a small-dynamic footprint that is used for many cloud applications.  Many applications use the OpenJ9 to run their applications, such as the Apache OpenWhisk, IBM FHIR Server and Open Liberty.

I learned a few things about running Java applications with the OpenJ9 VM in Docker:

  1. Eclipse OpenJ9 knows about modern applications
  2. Tweak Your Settings
  3. Review your Settings

1.   Eclipse OpenJ9 knows about modern applications

The Eclipse OpenJ9 team smartly realized many Java applications are in a container or namespace or virtual machine which has a runtime determined memory allocation.  For instance, Kubernetes may scale the memory available to a Java Container from 4G to 8G. As such, the OpenJ9 VM automatically adjust the minimum and maximum heap sizes based on the available memory in the container.

There are plenty of nobs to tweak. Further, the Eclipse team has some compelling research on performance and places to look to tweak my application.

2.   Tweak your settings

I scanned through the JVM -XX Options and found -XX:InitialRAMPercentage / -XX:MaxRAMPercentage.  These options combined with -XX:[+|-]UseContainerSupport

, the default, enable the VM to allocate a fraction of the available memory to the JVM.  I tried this with a Docker container assigned 2GB Memory.

-XX:InitialRAMPercentage=50.00

-XX:MaxRAMPercentage=90.00

3.   Review and Test Your Settings

I turned on the -verbose:gc setting, and started my VM and ran some load.

I waited for a steady state and checked my available memory, and saw the 469M free of 858M total.

<gc-end id=”443″ type=”scavenge” contextid=”439″ durationms=”57.408″ usertimems=”223.188″ systemtimems=”0.172″ stalltimems=”4.439″ timestamp=”2021-12-20T18:00:43.360″ activeThreads=”4″>

<mem-info id=”444″ free=”469525144″ total=”858914816″ percent=”54″>

<mem type=”nursery” free=”269655128″ total=”468451328″ percent=”57″>

<mem type=”allocate” free=”269655128″ total=”349700096″ percent=”77″ />

<mem type=”survivor” free=”0″ total=”118751232″ percent=”0″ /> </mem>

 <mem type=”tenure” free=”199870016″ total=”390463488″ percent=”51″ macro-fragmented=”99381968″>

<mem type=”soa” free=”180346432″ total=”370939904″ percent=”48″ />

 <mem type=”loa” free=”19523584″ total=”19523584″ percent=”100″ /> </mem>

I tweaked the memory based on the Garbage Collection log and used the tools as mentioned in the OpenJ9 docs. You can also see some more of the enhancements for Containers that OpenJ9 has added.

Go forth, tweak the settings for the container and best wishes. Please comment if I can help.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.