Skip to content

HOWTO tune garbage collection

Why do that

By default the garbage collection favor throughput, but can end up causing long interruptions. You can

What to do

First of all, retrieve the latest topology configuration file. Do not forget to synchronize your platform configuration

cd $PUNCHPLATFORM_CONF_DIR
git pull

Then, locate the following lines in your topology file:

"storm_settings" : {
    [...]
    "topology.worker.childopts" : "-server -Xms128m -Xmx128m",
    [...]
}

Simply add the gc options you want as part of the topology.worker.childopts parameter, and restart your channel.

Example

By default the gc will let the heap memory regularly grow, and periodically trigger to reduce it yielding the typical memory pattern shown hereafter:

image

The following illustrates how to force the gc to run more often in a way to reduce the stop-the-world pause.

"storm_settings" : {
    [...]
    "topology.worker.childopts" : "-server XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:GCTimeRatio=2 -Xms128m -Xmx128m",
    [...]
}

Here is the typical pattern observed with such settings. Such settings will reduce the occurrence of out of memory errors. Watchout in this example the GCTimeRatio is set to an extreme value in order to give the gc plenty of resource.

image

Tip

refer to the many excellent online resource. For java 8 have a look at the oracle tuning guid.