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
    评论
Spring Boot整合GeoMesa Cassandra是为了利用GeoMesa库的强大地理空间处理能力,与Cassandra NoSQL数据库结合,以便在Spring应用中方便地执行地理数据的CRUD操作。GeoMesa是一个高度可扩展的开源框架,它抽象了底层的数据存储,使得开发者能够更专注于业务逻辑。 以下是整合步骤: 1. 添加依赖: 在你的`pom.xml`文件中添加GeoMesa和Spring Data Cassandra的依赖: ```xml <dependency> <groupId>org.locationtech.geomesa</groupId> <artifactId>geomesa-spring-boot-starter-cassandra</artifactId> <version>XX.YY.ZZ</version> <!-- 用最新版本替换 --> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-cassandra</artifactId> </dependency> ``` 记得替换版本号为最新的稳定版。 2. 配置GeoMesa Cassandra:在`application.properties`或`application.yml`中配置Cassandra连接信息,包括主机、端口、用户名、密码等。 3. 创建数据源:在Spring Boot应用中,使用Spring Data Cassandra的Repository接口来定义地理空间数据源。例如,假设你有一个`Feature`实体映射到GeoMesa中的一个表,你可以创建一个类似这样的Repository接口: ```java public interface FeatureRepository extends GeoMesaFeatureDao<Feature, UUID> { // CRUD operations List<Feature> findByBbox(BoundingBox bbox); Feature findById(UUID id); void save(Feature feature); void deleteById(UUID id); } ``` 4. 使用Repository:注入`FeatureRepository`并进行CRUD操作: ```java @Autowired private FeatureRepository featureRepository; public void createFeature(Feature feature) { featureRepository.save(feature); } public Feature getFeatureById(UUID id) { return featureRepository.findById(id); } public void updateFeature(Feature updatedFeature) { featureRepository.save(updatedFeature); } public void deleteFeature(UUID id) { featureRepository.deleteById(id); } ```

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值