Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set heap memory in cassandra on docker

I am using a Cassandra docker (official Cassandra docker) to setup my local env. As part of this I want to limit the amount of memory the Cassandra is using in my local deployment.
By default Cassandra has a pre defined way to set its memory.
I found references to some info saying that i can use JVM_OPTS to set this values but it does not seem to take hold.
I am looking for a way to set up this values without creating my own Cassandra docker.

Docker command that is used to run container:

docker run -dit --name sdc-cs --env RELEASE="${RELEASE}" \
   --env CS_PASSWORD="${CS_PASSWORD}" --env ENVNAME="${DEP_ENV}" \
   --env HOST_IP=${IP} --env JVM_OPTS="-Xms1024m -Xmx1024m" \
   --log-driver=json-file --log-opt max-size=100m \
   --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 \
   --volume /etc/localtime:/etc/localtime:ro \
   --volume ${WORKSPACE}/data/CS:/var/lib/cassandra \
   --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments \
   --publish 9042:9042 --publish 9160:9160 \
   ${PREFIX}/sdc-cassandra:${RELEASE} /bin/s

Any advice will be appreciated!

like image 648
Raven Avatar asked Feb 11 '18 08:02

Raven


People also ask

How do I assign a memory to a Docker container?

Set Maximum Memory Access To limit the maximum amount of memory usage for a container, add the --memory option to the docker run command. Alternatively, you can use the shortcut -m . Within the command, specify how much memory you want to dedicate to that specific container.

What is cassandra heap size?

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.


1 Answers

I am using docker-compose, in the docker-compose.yml file I set the following env variables. It seems to work.

environment:
    - HEAP_NEWSIZE=128M
    - MAX_HEAP_SIZE=2048M
like image 156
Erkan Şirin Avatar answered Sep 28 '22 20:09

Erkan Şirin