tobert / cassandra-docker

Cassandra in Docker
https://registry.hub.docker.com/u/tobert/cassandra/
Apache License 2.0
130 stars 56 forks source link

Wouldn't run on CoreOS without manually specifying memory #8

Closed kristofferpeterhansel closed 9 years ago

kristofferpeterhansel commented 9 years ago

So I am fairly new to Docker (and CoreOS - lots of things to play with). But I figured I'd give it a go with making a deployment of the solution we are currently developing. And since we are using Cassandra, this image seemed like a solid place to start.

But as one may guess from the subject, it wouldn't run. Looking a bit around for answers I discovered the answer in /srv/cassandra/log/console.log where this message kept appearing:

OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000731400000, 3293577216, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 3293577216 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /tmp/hs_err_pid1.log

Adding a -m with sufficient memory (I started it out at 2g) fixed the issue for me. Not sure if it is CoreOS specific or what's going on. Couldn't see anything in your Dockerfile that should provoke issues like that anyway.

tobert commented 9 years ago

Hmm. Can you try setting the heap smaller in /srv/cassandra/conf/sproks/cassandra.yaml?

-Xmx and -Xms should be the same and should be sized around 1/2 the RAM available on the machine. 1GB is a good choice. Change -Xmn800M to be 1/4 to 1/2 of that or 256M.

Once Docker has introspection abilities, this will get set automatically.

kristofferpeterhansel commented 9 years ago

Yeah alright. I guess I glanced over that log message a bit too quickly.

Reducing the memory settings in /srv/cassandra/conf/sproks/cassandra.yaml seems like the way to go. Allthough it is a bit cumbersome if you just want something up and running without messing too much with the installation.

Now that I did read the log output message. Isn't it a bit strange that the JVM will work in a container that has been constrained to 2 GB of memory when is obviously failing to allocate more than that without the constraint?

tobert commented 9 years ago

Memory overcommit lets you allocate memory that isn't available. It's only when you write to the pages that it blows up.

I'm going to change the defaults to have Cassandra run in around 512MB of memory until introspection is available.

tobert commented 9 years ago

The new default as of 2f5cfb4a5e3cb4744b87ad9f022fd3e155ee4ef7 is 1GB heap with 256MB of new gen. Additionally, that commit adds the -heap and -new options which allow you to set your heap/new size at startup, which should cover your case.

See also: #18