Heap Size Ergonomics in docker containers
Ruslan Synytsky
rs at jelastic.com
Mon Oct 30 18:06:04 UTC 2017
Hi guys, I'm interested in improvements in this direction as well. Let me
share the statistical experience from Jelastic customers who run Java
stacks in containers for a long time.
We set the minimum Xmx to 32m by default as we believe majority wants to
start from the minimum, specifically in the "micro" world (services,
containers). G1 GC provides good enough elasticity of memory allocation.
You can grow up quickly, and important to scale down later when the load
goes away.
By default, Xmx is 80% of available RAM with container limits. It works
great for the majority of our users. We track OOM Kill events and send
alerts to the users. So the numbers are based on the real end users
applications.
We keep 80% from max by default always, even if users allocate a bigger
amount of RAM, for two reasons: 1 - it's easier to remember the defaults
and 2 - unused resources are not reserved with containers, so if Java does
not use it - no problem, they are free, and at the same time additional
memory available for native non-heap data or for other processes, just like
an insurance.
Big memory and big data solutions - everything like this requires a
fine-tuning, the customers who run such stacks definitely do not rely on
the default heuristic. You can always find instructions and recommended RAM
usage configs for these stacks. Some solutions even use direct memory
access, a small heap size is preferable for them. In general, it means you
have to do a customization if you want to get a stable solution.
To make it simple, we came up with a supervisor script
<https://github.com/jelastic-jps/java-memory-agent/blob/master/scripts/supervisor.sh>
that
applies custom memory configs
<https://github.com/jelastic-jps/java-memory-agent/blob/master/scripts/memoryConfig.sh>.
As result, customers can define the needed parameters with env variables in
a container if they do not want to rely on the heuristic.
Btw, is there any guaranteed way to pass Xmx and Xms to java process w/o
any external scripts? I mean, it will be cool if java can check env
variable like XMX and if it exists apply.
Hope my feedback can help to find a better solution.
Regards
--
Ruslan
CEO @ Jelastic <https://jelastic.com/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/hotspot-gc-dev/attachments/20171030/e5a3bee9/attachment.htm>
More information about the hotspot-gc-dev
mailing list