Oracle Commerce – Initial JVM Settings

Introduction

A lot of Oracle Commerce clients inquire about JVM setting.  Optimal settings can only be obtained after tuning activities, which can take many iterations of collecting data, analyzing the logs and fine tuning the JVM settings. This cycle is repeated many times. It usually takes a few iterations until throughput and performance are good enough. Therefore these settings are very unique for each client and it’s not possible to have a “one size fits all” solution. But to provide some guidance to those that are starting on the journey to configure and/or setup their environment, this article provides some JVM setting that can be used as a starting point.

Also, due to popular demand this article is restricted to versions 7 and 8 of the Hotspot JVM.

Common Settings

Make Xmx and Xms the same size. 

For example, -Xmx8g -Xms8g

There are a couple of reasons why Xms and Xmx should be the same in production

If you set the minimum (Xms) and maximum (Xms) heap sizes to different values the JVM will eventually increase the heap size to the maximum value. Each time the JVM increases the heap size it asks the OS for additional memory, which adds to the response time. Also, since the JVM never reduce the heap size, it’s best to set the same value at the beginning.

Another reason to start heap size with maximum value is that with a smaller heap size more frequent GC’s will happen.

As far as the heap size, you could start with 8 GB and change to a larger value as needed.

set max perm size: -XX:MaxPermSize=512m

512 is pretty common, but sometimes the size needs to be bumped up to 768.

Add -XX:+DisableExplicitGC

In production you should avoid calls to System.gc() because they will cause stop-the-world GC events. Therefore,  you should let the JVM decide when it’s time to run garbage collection.

On new JVM’s where heap size is at least 16 GB, use the G1 collector “-XX:+UseG1GC”

If you are running Java 1.7 update 4 or later and your heap size is at least 16 GB you should use the G1 collector, which yields a better throughput. Otherwise, just leave it on the default collector, ParallelGC.

Please read Getting Started with the G1 Garbage Collector, if you need more details.

if GC is not G1, add -XX:NewRatio=3

Old/young ratio of 3 is a good starting point.

Add -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000

By default, the RMI subsystem forces a full garbage collection once per minute. You don’t want to force GC’s every minute in production, specially under load. Therefore set the RMI interval to once per hour.

Set -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Xloggc:mygc.log

Since garbage collection logging has no performance impact to the system, you can have it enable in production all the time. You should also monitor these logs from time to time, especially in preparation for heavy load, such as holidays and Black Friday.

 

You can get more information about JVM 7 or 8 settings at Java HotSpot VM Options

Add Your Comment