JDK Tuning in Liferay

JDK Tuning or Memory Tuning is generally considered one of the thing while making Performance related Optimisations . Generally in tomcat you can do it at $CATALINA_HOME/bin/setenv.sh.

Depending on your system RAM this can vary . A general recommendation on 4 GB RAM may be

JAVA_OPTS="$JAVA_OPTS -XX:NewSize=700m -XX:MaxNewSize=700m -Xms2048m -Xmx2048m -XX:MaxPermSize=512m -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:SurvivorRatio=20 -XX:ParallelGCThreads=8"

 

Scenarios : When to go for JDK Tuning

Problem 1 : “Out of memory” or “concurrent mode failure”
Solution : Solved by increasing GC size

Problem 2 : Throughput is drastically affected by large % of time in GC.
Solution : Solved by decreasing GC size

Problem 3: You want to have enough GC heap space to handle your high capacity situations.At the same time you don’t want to have so much GC heap such that your throughput does down.
Solution : One option is to try to split the application across multiple JVMs to keep smaller heap spaces.

Few more scenarios when you should go for JDK Tuning :

  1. If the logs show 1-3 seconds or more, GC tuning is necessary.
  2. If the logs show less than 1% of the time spent in GC, then you
    don’t need to tune the GC.
  3. If the logs show just 0.1-0.3 seconds in GC, then you don’t need to tune the GC.
  4. If the logs show more than 10% of the time spent in GC, then GC tuning is necessary.

Note : Many problems are solved not by GC tuning, but through application code refactoring. Thus, GC tuning should be done when application code refactoring is not an option.

Example

 

Reference : Liferay Performance User Group .