JVM tuning
JVM tuning is an operation that should be done after performance tests or during production. JVM configuration affects the Java application's performance. There are two necessary configurations:
Memory settings (such as heap configuration)
Garbage collector settings
There are a lot of publications about JVM tuning. Thus, in this recipe, we will only mention the main aspects.
How to do it…
Every JVM setting can be set in JAVA_OPTS
(Java Environment Options). A great place to do it is in the ${TOMCAT_HOME}/bin/setenv.sh
file.
First, let's set a proper garbage collector. The best option for portal systems is Concurrent Collector or G1 (in Java 8). These garbage collectors perform most of their work concurrently with only a small period of stop-the-world time. These garbage collectors give the best performance. The typical setting is as follows:
JAVA_OPTS = "$JAVA_OPTS -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX+CMSParallelRemarkEnabled -XX:ParallelGCThreads=8 -XX:+CMSScavengeBeforeRemark...