Differences in the default heap settings between JBoss EAP 7 and JBoss EAP 8 for OpenShift
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 7.0 for OpenShift
- 8.0 for OpenShift
Issue
- In JBoss EAP 7 for OpenShift,
-Xmsand-Xmxjava options are set by default, but not in JBoss EAP 8. - In JBoss EAP 8 for OpenShift,
-XX:MaxRAMPercentage=80.0is 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 variable | Purpose | Default |
|---|---|---|
| JAVA_MAX_MEM_RATIO | Sets Xmx | default: 50 percent of the available memory of the container |
| JAVA_INITIAL_MEM_RATIO | Sets Xms | default: 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
| Intent | EAP 7 | EAP 8 |
|---|---|---|
| Container limits detection | EAP 7 relies on its own script for detecting cgropus settings, i.e. container awareness: ${JBOSS_CONTAINER_JAVA_JVM_MODULE}/container-limits | EAP 8 DOES NOT rely on its own script, instead relies on OpenJDK CPP detection. |
| Default JVM settings | EAP 7 have its own settings | EAP 8 relies on Red Hat's OpenJDK default JVM settings, e.g. 80% JVM heap size |
| Initialization | EAP 7 starts from /opt/eap/bin/openshift-launch.sh | EAP 8 starts from /opt/jboss/container/wildfly/run/run |
| Default java-default-options | EAP 7 has a long java-default-options script with the container limit detection | EAP 8 does not have container detection on this script but set default JVM settings |
| JVM initial heap settings | EAP 7 uses JAVA_MAX_MEM_RATIO (at 50) and JAVA_INITIAL_MEM_RATIO at 25 for setting JVM defaults | EAP 8 uses MaxRAMPercentage at 80%, in case JAVA_MAX_MEM_RATIO is not defined for JVM default |
Root Cause
- For Java container awareness see: This content is not included.Java Container awareness
- Red Hat's build of OpenJDK containers changed the default from 50% to 80% as described on the solution UBI 9 OpenJDK images have MaxPercentage is set at 50/50 given This content is not included.OPENJDK-559 Consider setting -XX:MaxRAMPercentage to a higher default.
- For
JAVA_MAX_MEM_RATIOsee the solution Using JAVA_MAX_MEM_RATIO on container JBoss EAP 7/8 image. - EAP 8 does not rely on its own script to detect container awareness.
- Regarding the behavior of MinHeapSize in Red Hat OpenJDK container, see the solution Unable to set MinHeapSize elastically in Red OpenJDK UBI images.
Diagnostic Steps
- Verify VM.info for container details (
$ jcmd $PID VM.info) - Get inspect for container verification
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.