Tuning garbage collection
Choose different garbage collection options for best performance in different environments.
Some garbage collection options typically chosen include:
- Concurrent low pause collector: Use this collector in most cases.
This collector attempts to minimize "Stop the World" events. Avoiding these events can reduce
connection timeouts, such as with ZooKeeper, and may improve user experience. This collector is
enabled using the Java system property
-XX:+UseConcMarkSweepGC
. - Throughput collector: Consider this collector if raw throughput is
more important than user experience. This collector typically uses more "Stop the World" events
so this may negatively affect user experience and connection timeouts such as ZooKeeper
heartbeats. This collector is enabled using the Java system property
-XX:+UseParallelGC
. IfUseParallelGC
"Stop the World" events create problems, such as ZooKeeper timeouts, consider using theUseParNewGC
collector as an alternative collector with similar throughput benefits.
You can also affect garbage collection behavior by increasing the Eden space to accommodate new objects. With additional Eden space, garbage collection does not need to run as frequently on new objects.