Cassandra_调整占用内存大小

来源:互联网 发布:mac adb 工具下载 编辑:程序博客网 时间:2024/05/08 05:11


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.

Cassandra automatically calculates the maximum heap size (MAX_HEAP_SIZE) based on this formula:
max(min(1/2 ram, 1024MB), min(1/4 ram, 8GB)
For production use, you may wish to adjust heap size for your environment using the following guidelines:
  • 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.
Note: For more tuning tips, see Secret HotSpot option improving GC pauses on large heaps.

MAX_HEAP_SIZE

The recommended maximum heap size depends on which GC is used:
Hardware setupRecommended MAX_HEAP_SIZEOlder computersTypically 8 GB.CMS for newer computers (8+ cores) with up to 256 GB RAMNo more 14 GB.
The easiest way to determine the optimum heap size for your environment is:
  1. 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"
  2. Enable GC logging.
  3. Check the logs to view the heap used by that node and use that value for setting the heap size in the cluster:
Note: This method decreases performance for the test node, but generally does not significantly reduce cluster performance.

If you don't see improved performance, contact the DataStax Services team for additional help.

HEAP_NEWSIZE

This setting determines the amount of heap memory allocated to newer objects or young generation. Cassandra calculates the default value for this property (in MB) as the lesser of:
  • 100 times the number of cores
  • ¼ of MAX_HEAP_SIZE
As a starting point, set HEAP_NEWSIZE to 100 MB per physical CPU core. For example, for a modern 8-core+ machine:
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,

原文地址:

http://docs.datastax.com/en/cassandra/2.1/cassandra/operations/ops_tune_jvm_c.html#opsTuneJVM__tuning-the-java-heap


0 0
原创粉丝点击