Cassandra_调整占用内存大小


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 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.
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


  • 4
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值