Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Best practices for JVM memory management in Docker containers #361

Open
jetztgradnet opened this issue Oct 16, 2017 · 3 comments
Open

Best practices for JVM memory management in Docker containers #361

jetztgradnet opened this issue Oct 16, 2017 · 3 comments

Comments

@jetztgradnet
Copy link

Which lab is it that you're having issues with?
Lab: Docker for Java Developers

Description

When deploying Java applications in production one usually specifies the amount of memory available to the JVM (-Xmx) and other assorted configuration settings. Unfortunately, this is (usually) static configuration and therefore fixed in the container image. When specifying memory constraints (using cgroups) this is unfortunately not picked up by the JVM automatically, so there should be a section on memory management for dockerized Java apps.

Java9 and Java8 > u131 provide limited support for this, see https://bugs.openjdk.java.net/browse/JDK-8170888 for details.

For older Java releases there is a good script from @fabric8io-images: https://github.com/fabric8io-images/java/blob/master/images/centos/openjdk8/jdk/container-limits

Also, it is not easy to calculate the amount of JVM heap and the resulting cgroup limits, as the JVM also needs memory for other things, e.g. metaspace, JIT, ...

A few words on the whole topic of JVM memory management for containers would be a very good addition. Articles like https://developers.redhat.com/blog/2017/03/14/java-inside-docker/ provide a good starting point.

@arun-gupta
Copy link
Contributor

@PaulSandoz FYI, could not find Mikael's github handle.

@pgordon9
Copy link

pgordon9 commented Nov 2, 2018

Would love to see points on how to estimate how much off-heap memory is typically needed.

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

No branches or pull requests

5 participants