Database Reference
In-Depth Information
Tuning the JVM
Try tuning the options passed to the JVM at startup for better performance. The key JVM op-
tions included in cassandra.in.shand guidelines for how you might tweak them are illustrated in
Table 11-1 . If you want to change any of these values, simply open the cassandra.in.shile in a
text editor, change the values, and restart.
Table11-1.Java performance tuning options
Java option
Setting guidelines
Heap Min and Max By default, these are set to 256MB and 1GB, respectively. To tune these, set them higher
(see following note) and to the same value.
Assertions
By default, the JVM is passed the -ea option to enable assertions. Changing this option
from -ea to -da (disable assertions) can have a positive effect on performance.
Survivor Ratio
The Java heap is broadly divided into two object spaces: young and old. The young
space is subdivided into one for new object allocation (called “eden space”) and another
for new objects that are still in use. Older objects still have some reference, and have
therefore survived a few garbage collections, so the Survivor Ratio is the ratio of eden
space to survivor space in the young object part of the heap. Increasing the ratio makes
sense for applications with lots of new object creation and low object preservation; de-
creasing it makes sense for applications with longer-living objects. Cassandra sets this
value to 8 by default, meaning that the ratio of eden to survivor space is 1:8 (each surviv-
or space will be 1/8 the size of eden). This is fairly low, because the objects are living
longer in the memtables. Tune this setting along with MaxTenuringThreshold .
MaxTenuringThreshold Every Java object has an age field in its header, indicating how many times it has been
copied within the young generation space. They're copied (into a new space) when they
survive a young generation garbage collection, and this copying has a cost. Because long-
living objects may be copied many times, tuning this value can improve performance. By
default, Cassandra has this value set at 1. Set it to 0 to immediately move an object that
survives a young generation collection to the tenured generation.
This instructs the JVM on what garbage collection (GC) strategy to use; specifically, it
enables the ConcurrentMarkSweep algorithm. This setting uses more RAM, and uses more
CPU power to do frequent garbage collections while the application is running in order
to keep the GC pause time to a minimum. When using this strategy, it's important to set
the heap min and max values to the same value, in order to prevent the JVM from hav-
ing to spend a lot of time growing the heap initially. It is possible to tune this to -
XX:+UseParallelGC , which also takes advantage of multiprocessor machines; this will give
you peak application performance, but with occasional pauses. Do not use the Serial GC
with Cassandra.
UseConcMarkSweepGC
The majority of options in the include configuration file surround the Java settings. For example,
the default setting for the maximum size of the Java heap memory usage is 1GB. If you're on
Search WWH ::




Custom Search