Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cassandra doesn't run with a low memory on docker #277

Open
rodrigorodrigues opened this issue Feb 10, 2024 · 5 comments
Open

Cassandra doesn't run with a low memory on docker #277

rodrigorodrigues opened this issue Feb 10, 2024 · 5 comments

Comments

@rodrigorodrigues
Copy link

Hi all,

I'm trying to run Cassandra with the minimum memory as possible on docker but the server kills after a while, is there anyway to use Cassandra with a minimum memory possible? It could disable most all features like authorization, cluster just need a simple single node to store data in a fast way.

cassandra:
  image: 'cassandra:latest'
  environment:
    - 'HEAP_NEWSIZE=10M'
    - 'MAX_HEAP_SIZE=200M'
  ports:
    - '9042:9042'
  deploy:
    resources:
      limits:
        cpus: "0.5"
        memory: "300MB"
@tianon
Copy link
Member

tianon commented Feb 12, 2024

Hmm, I'm not sure. I've never had much luck with limiting Cassandra explicitly -- using --env MAX_HEAP_SIZE='128m' --env HEAP_NEWSIZE='32m' is the best I've found to keep the memory usage low (which is very similar to what you're using). If you get rid of the explicit limit (or raise it), does that help?

(This might be better suited to a Java or Cassandra specific forum, since it's not really specific to the container image, and then you might find folks with more knowledge of Java and Cassandra memory usage and keeping it within sane thresholds. 😅)

@LaurentGoderre
Copy link
Member

I haven't tried yet but according to the docs, that isn't how you set those settings.

https://cassandra.apache.org/doc/latest/cassandra/getting-started/configuring.html#environment-variables

@LaurentGoderre
Copy link
Member

This is the smallest I have managed to get it:

services:
  cassandra:
    image: 'cassandra:latest'
    environment:
      JVM_OPTS: -Xmn64m -Xms128m -Xmx500m
    ports:
      - '9042:9042'
    deploy:
      resources:
        limits:
          cpus: "0.5"
          memory: "500MB"

@tianon
Copy link
Member

tianon commented Apr 23, 2024

I think if you run it hard enough it'll balloon higher than 500M though, so your limit will likely activate OOM killing. I'm not familiar enough with memory management in Java to say for sure exactly how much higher it'll go, but I've definitely seen it go higher.

@LaurentGoderre
Copy link
Member

I wouldn't be surprised. I think the lesson here is that 300mb is just too low for latest cassandra to run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants