Skip to content

Commit ab660c6

Browse files
author
vroyer
committed
Add CASSANDRA_CGROUP_MEMORY_LIMIT env var
1 parent a6cc2da commit ab660c6

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,18 @@ LOGBACK_org_elassandra_cluster_service
9090
LOGBACK_org_elasticsearch
9191
```
9292

93+
### cgroup memory limit
94+
95+
If CASSANDRA_CGROUP_MEMORY_LIMIT is set to **true** (default is **false**),
96+
add the following JVM properties to the /etc/cassandra/jvm.options file.
97+
This will restrict maximum heap size to cgroup limit.
98+
99+
```
100+
-XX:+UnlockExperimentalVMOptions
101+
-XX:+UseCGroupMemoryLimitForHeap
102+
-XX:MaxRAMFraction=2
103+
```
104+
93105
### Kubernetes
94106

95107
A **ready_probe.sh** script can be used for readiness probe as follow:

docker-entrypoint.sh

+7-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,13 @@ if [ "$1" = 'cassandra' ]; then
159159
if [ "$LOCAL_JMX" = "no" ]; then
160160
export JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=$POD_IP"
161161
fi
162-
162+
163+
: ${CASSANDRA_CGROUP_MEMORY_LIMIT='false'}
164+
165+
# Specifies if heap size should be limited by cgroup constraints
166+
if [ "${CASSANDRA_CGROUP_MEMORY_LIMIT}" = 'true' ]; then
167+
export JVM_OPTS="$JVM_OPTS -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=2"
168+
fi
163169
fi
164170

165171
exec "$@"

0 commit comments

Comments
 (0)