Chapter 2. Java Virtual Machine settings
Java Virtual Machine tuning might be divided into sections like memory or GC. Below is a list of helpful configuration parameters and a guide how to adjust them.
2.1. Memory settings Copy linkLink copied to clipboard!
Adjusting memory size is one of the most crucial step in Red Hat Data Grid tuning. The most commonly used JVM flags are:
-
-Xms
- Defines the minimum heap size allowed. -
-Xmx
- Defines the maximum heap size allowed. -
-Xmn
- Defines the minimum and maximum value for the young generation. -
-XX:NewRatio
- Define the ratio between young and old generations. Should not be used if -Xmn is enabled.
Using Xms
equal to Xmx
will prevent JVM from dynamically sizing memory and might decrease GC pauses caused by resizing. It is a good practice to specify Xmn
parameter. This guaranteed proper behavior during load peak (in such case Red Hat Data Grid generates lots of small, short living objects).
2.2. Garbage collection Copy linkLink copied to clipboard!
The main goal is to minimize the amount of time when JVM is paused. Having said that, CMS is a suggested GC for Red Hat Data Grid applications.
The most frequently used JVM flags are:
-
-XX:MaxGCPauseMillis
- Sets a target for the maximum GC pause time. Should be tuned to meet the SLA. -
-XX:+UseConcMarkSweepGC
- Enables usage of the CMS collector. -
-XX:+CMSClassUnloadingEnabled
- Allows class unloading when the CMS collector is enabled. -
-XX:+UseParNewGC
- Utilize a parallel collector for the young generation. This parameter minimizes pausing by using multiple collection threads in parallel. -
-XX:+DisableExplicitGC
- Prevent explicit garbage collections. -
-XX:+UseG1GC
- Turn on G1 Garbage Collector.
2.3. Other settings Copy linkLink copied to clipboard!
There are two additional parameters which are suggested to be used:
-
-server
- Enables server mode for the JVM. -
-XX:+ UseLargePages
- Instructs the JVM to allocate memory in Large Pages. These pages must be configured at the OS level for this parameter to function successfully.
2.4. Example configuration Copy linkLink copied to clipboard!
In most of the cases we suggest using CMS. However when using the latest JVM, G1 might perform slightly better.
32GB JVM
32GB JVM with G1 Garbage Collector
-server -Xmx32G -Xms32G -Xmn8G -XX:+UseG1GC
-server
-Xmx32G
-Xms32G
-Xmn8G
-XX:+UseG1GC