Closed ffarozan closed 5 years ago
Hello @ffarozan,
You can customize Java startup params by overriding /etc/cassandra/jvm.options
, e.g.
docker run --rm --name cassandra -d cassandra:3.11.4
docker cp cassandra:/etc/cassandra/jvm.options jvm.options
docker stop cassandra
sed -i 's/#-Xms4G/-Xms1G/' jvm.options
sed -i 's/#-Xmx4G/-Xmx2G/' jvm.options
docker run --rm --name cassandra -d -v $(pwd)/jvm.options:/etc/cassandra/jvm.options cassandra:3.11.4
Supposedly it can be configured through the JVM_OPTS
environment variable just as through non-containerized Cassandra
http://cassandra.apache.org/doc/latest/getting_started/configuring.html#environment-variables
https://github.com/docker-library/cassandra/issues/12
However it encounters an error of Initial heap size set to a larger value than the maximum heap size
https://github.com/docker-library/cassandra/issues/172
You might also like Docker's memory limit flags which is just a -m 3.5G
as the minimum value Cassandra will start with on my machine
https://docs.docker.com/config/containers/resource_constraints/#limit-a-containers-access-to-memory
I think MAX_HEAP_SIZE
and HEAP_NEWSIZE
are the environment variables you want to tweak here: https://docs.datastax.com/en/archived/cassandra/3.0/cassandra/operations/opsTuneJVM.html#opsTuneJVM__tuning-the-java-heap
See also our cassandra-basics
test which uses these successfully to run Cassandra on an otherwise busy/loaded machine: https://github.com/docker-library/official-images/blob/487e262c8f551d359f951ebfb6995c7630afcb6e/test/tests/cassandra-basics/run.sh#L17-L18
Hi @tianon,
I like your suggestion, but I have an extra note.
HEAP_NEWSIZE
is for Xmn
, not for Xms
.
And here is something from Cassandra's jvm.options
that you should know about Xmn
before adjusting it:
# Young generation size is automatically calculated by cassandra-env
# based on this formula: min(100 * num_cores, 1/4 * heap size)
#
# The main trade-off for the young generation is that the larger it
# is, the longer GC pause times will be. The shorter it is, the more
# expensive GC will be (usually).
#
# It is not recommended to set the young generation size if using the
# G1 GC, since that will override the target pause-time goal.
# More info: http://www.oracle.com/technetwork/articles/java/g1gc-1984535.html
#
# The example below assumes a modern 8-core+ machine for decent
# times. If in doubt, and if you do not particularly want to tweak, go
# 100 MB per physical CPU core.
#-Xmn800M
If it is already supported, please provide information on how to customize. I could not find this information in documentation.