cloudstax / firecamp

Serverless Platform for the stateful services
https://www.cloudstax.io
Apache License 2.0
209 stars 20 forks source link

auto-limit java heap size #40

Closed jazzl0ver closed 6 years ago

jazzl0ver commented 6 years ago

Let's add these keys to JVM settings for all services:

-XX:+PrintCommandLineFlags -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap

Thus we wouldn't need to limit the java heap size, it will be done automatically by reading container limits.

JuniusLuo commented 6 years ago

Thanks for the suggestion!

It is probably not good to enable the experimental vm options. Not sure whether it will impact the service stability. Do not hear any service recommends to use the experimental vm options.

Inherit the container limits may have unexpected limits. Currently the container max memory is not a must-have parameter when creating the service. The default container max memory is -1, which allows the container to use as many memory as possible. Usually one node will only run one stateful service. So the stateful service could safely use all memory. JVM process may have the off-heap handling to reduce the java GC imapct. For example, Cassandra could have offheap memtable, see Cassandra JVM tuning. It would be better to separate the configs for JVM heap and container max memory.

jazzl0ver commented 6 years ago

Thank you for the explanation!