How to restrict Cassandra to use fixed memory

cassandra

We are using Cassandra in order to collect data from Thingsboard. The memory it started with was 4GB (after executing the systemctl status for Cassandra) and after 15 hours it has reached up to 9.3GB. I am unsure about the reason for this increase in memory, I want to know if there is any way to control it or to restrict it to use a fixed amount of memory without data loss.

Best Answer

You can control the heap size with the MAX_HEAP_SIZE setting in the cassandra-env.sh, however Apache Cassandra also has many components that utilise off-heap memory. Notably, compression offsets, bloomfilters, chunk cache, and potentially memtables. There are ways to tune how much memory these use, however they are always going to use some memory, and things like compression offsets and bloomfilters will grow with data size. Having said that, memory usage shouldn't grow unbounded and at some point will flatten out unless you continuously increase data size without adding more nodes.