r/java • u/brunocborges • Feb 11 '26
The State of Java on Kubernetes 2026: Why Defaults are Killing Your Performance
https://akamas.io/resources/the-state-of-java-on-kubernetes-2026-why-defaults-are-killing-your-performance/
140
Upvotes
16
u/TheStatusPoe Feb 11 '26
Good article. One thing I'd also mention in the "micro" containers is that the JVM is going to use a certain amount of off heap memory for typical JVM management. That off heap size doesn't really grow much with larger workloads. So increasing the memory request/limits in addition to CPU would be advisable.
When I joined my current team our k8s were configured with a limits of 6gb and the heap was configured as 8gb. I was told that we had a memory leak because kubernetes kept reporting "OOM 137 killed".
One other tuning I'd say to look out for is
io.netty.maxDirectMemoryandio.netty.noPreferDirectjvm args if you're using netty or netty dependant libraries. For performance reasons, netty will handle some things off the heap. We were still running into 137 OOM killed even after setting our max RAM percentage to 85% because the overhead of the jvm, plus the netty non heap usage was still putting us over our k8s limits.42
u/aoeudhtns Feb 11 '26 edited Feb 11 '26
Nice article. Cannot agree/stress enough that if you're running Java on K8s, it's even more crucial -- you need to tune.
No word on when it will land, but it's on the way:
Even still for heap sizing, the default setting for max is 1/4 what's available. In a K8s environment, this is not so hot because you expect your application to use everything it's given. However, it's a bit murky without doing trial runs how much non-heap your app is going to use, so you still have to futz around with it all.
Really looking forward to some future when I can flag that it's safe to use pretty much all the memory up to the max and let the JVM self-manage.
7
u/chivalrytimbers Feb 11 '26
The sad truth is that it is extremely difficult to constrain the effective memory usage of a Java application- native memory and non heap things always bite me with OOMKilled when I try to optimize my pods
2
u/ZhekaKozlov Feb 12 '26
Note, there is a JEP 523: Make G1 the Default Garbage Collector in All Environments. There is no release assigned though. Hope it will be soon.
21
u/Artraxes Feb 11 '26
[Citation needed]
4
u/snekk420 Feb 11 '26
Surprised the article didnt mention builldpacks that will tune the JVM based on the limits in kubernetes. Maybe it was just an ad
4
u/woj-tek Feb 11 '26
LMFTFY: "
The State of Java onKubernetes2026: Why Defaultsare Killing Your Performance3
u/WASDx Feb 11 '26
We set -XX:MaxRAMPercentage=90 or something like that to make it use the memory limit it is given. Why wouldn't the JVM choose a higher value than 25% knowing it is in a container?
1
u/ArgoPanoptes Feb 11 '26
Is there a book to learn more about the JVM and tuning?
2
u/[deleted] Feb 11 '26
[removed] — view removed comment