Cassandra 下面的运行环境基于Java , 可以调整Cassandra 的占用的资源大小
主要依据于以下两个参数:
MAX_HEAP_SIZE
HEAP_NEWSIZE
这两个参数位于 cassandra-env.sh 文件内
Determining the heap size
You might be tempted to set the Java heap to consume the majority of the computer's RAM. However, this can interfere with the operation of the OS page cache. Recent operating systems maintain the OS page cache for frequently accessed data and are very good at keeping this data in memory. Properly tuning the OS page cache usually results in better performance than increasing the Cassandra row cache.
max(min(1/2 ram, 1024MB), min(1/4 ram, 8GB)
- Heap size is usually between ¼ and ½ of system memory.
- Do not devote all memory to heap because it is also used for offheap cache and file system cache.
- Always enable GC logging when adjusting GC.
- Adjust settings gradually and test each incremental change.
- Enable parallel processing for GC, particularly when using DSE Search.
- Cassandra's GCInspector class logs information about any garbage collection that takes longer than 200 ms. Garbage collections that occur frequently and take a moderate length of time (seconds) to complete, indicate excessive garbage collection pressure on the JVM. In addition to adjusting the garbage collection options, other remedies include adding nodes, and lowering cache sizes.
MAX_HEAP_SIZE
Hardware setup | Recommended MAX_HEAP_SIZE |
---|---|
Older computers | Typically 8 GB. |
CMS for newer computers (8+ cores) with up to 256 GB RAM | No more 14 GB. |
- Set the maximum heap size in the cassandra-env.sh file to a high arbitrary value on a single node. For example:
MAX_HEAP_SIZE="12G"
- Enable GC logging.
- Check the logs to view the heap used by that node and use that value for setting the heap size in the cluster:
If you don't see improved performance, contact the DataStax Services team for additional help.
HEAP_NEWSIZE
- 100 times the number of cores
- ¼ of MAX_HEAP_SIZE
HEAP_NEWSIZE="800M"
A larger HEAP_NEWSIZE leads to longer GC pause times. For a smaller HEAP_NEWSIZE, GC pauses are shorter but usually more expensive,
原文地址: