Differences in the default heap settings between JBoss EAP 7 and JBoss EAP 8 for OpenShift

Solution Verified - Updated

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 7.0 for OpenShift
    • 8.0 for OpenShift

Issue

  • In JBoss EAP 7 for OpenShift, -Xms and -Xmx java options are set by default, but not in JBoss EAP 8.
  • In JBoss EAP 8 for OpenShift, -XX:MaxRAMPercentage=80.0 is set by default. How can this value be changed?
  • In JBoss EAP 8 for OpenShift, the initial heap size is too small for our workload, and frequent Full GCs cause degrading the system performance. Which environment variable can be used to change the initial heap size?

Resolution

Avoid setting Xmx directly, which decouples the size of the heap from the container size

JBoss EAP 7 for OpenShift

At container startup, a script located at /opt/jboss/container/java/jvm/java-default-options reads the cgroups limits and sets the heap size at 50% of the container available memory to -Xmx**, and 25% of the maximum java heap size to -Xms by default.
In this script the default are tunable via environment arguments:

Environment variablePurposeDefault
JAVA_MAX_MEM_RATIOSets Xmxdefault: 50 percent of the available memory of the container
JAVA_INITIAL_MEM_RATIOSets Xmsdefault: 25 percent of the available memory of the max heap

JBoss EAP 8 for OpenShift

The EAP cgroups script was removed and instead it relies on the OpenJDK layer for detection and default JVM settings, which sets MaxRAMPercentage, as described on Usage of Java flags InitialRAMPercentage and MaxRAMPercentage.

Red Hat's OpenJDK container default script set MaxRAMPercentage at 80.0% and InitialRAMPercentage is not specified. And this is directly related to How to modify JVM options (JAVA_OPTS) for JBoss EAP in Openshift.

Given container awareness, the initialization script allow JAVA_INITIAL_MEM_RATIO (for -XX:InitialRAMPercentage) and the value of JAVA_MAX_MEM_RATIO for -XX:MaxRAMPercentage). Those environment variables are preffered rather than Xmx and Xms direct setting.

Comparison

IntentEAP 7EAP 8
Container limits detectionEAP 7 relies on its own script for detecting cgropus settings, i.e. container awareness: ${JBOSS_CONTAINER_JAVA_JVM_MODULE}/container-limitsEAP 8 DOES NOT rely on its own script, instead relies on OpenJDK CPP detection.
Default JVM settingsEAP 7 have its own settingsEAP 8 relies on Red Hat's OpenJDK default JVM settings, e.g. 80% JVM heap size
InitializationEAP 7 starts from /opt/eap/bin/openshift-launch.shEAP 8 starts from /opt/jboss/container/wildfly/run/run
Default java-default-optionsEAP 7 has a long java-default-options script with the container limit detectionEAP 8 does not have container detection on this script but set default JVM settings
JVM initial heap settingsEAP 7 uses JAVA_MAX_MEM_RATIO (at 50) and JAVA_INITIAL_MEM_RATIO at 25 for setting JVM defaultsEAP 8 uses MaxRAMPercentage at 80%, in case JAVA_MAX_MEM_RATIO is not defined for JVM default

Root Cause

Diagnostic Steps

  1. Verify VM.info for container details ($ jcmd $PID VM.info)
  2. Get inspect for container verification
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.