How to set Cassandra (>2.0) JVM heap size of 8GB?

user1870400 picture user1870400 · Jan 12, 2016 · Viewed 10.6k times · Source

How to set Cassandra (>2.0) JVM heap size of 8GB? When I type in free -m it gives me the following. How can I set the Cassandra JVM heap size to 8GB?

             total       used       free     shared    buffers     cached
Mem:         16047      11336       4711          0         81       5814
-/+ buffers/cache:       5441      10606
Swap:            0          0          0

Answer

Aaron picture Aaron · Jan 12, 2016

As stated in the Tuning Java resources section of the documentation:

If you decide to change the Java heap sizing, both MAX_HEAP_SIZE and HEAP_NEWSIZE should should be set together in conf/cassandra-env.sh.

Inside cassandra-env.sh, search for this line:

#MAX_HEAP_SIZE="4G"

That line in the code happens after the MAX_HEAP_SIZE calculations have happened, so it works as an override. Uncomment it, and set it accordingly.

MAX_HEAP_SIZE="8G"

Be careful going above 8G. For guidance on tuning the JVM, I recommend Amy Tobey's Cassandra 2.1 Tuning Guide. She offers some tips for tuning CMS, as well as a great section on implementing the new G1GC.