Interview Prep/Kubernetes/Resources, autoscaling and scheduling

Memory usage of a Java service in a pod is much higher than the heap. How do you size it?

AdvancedScenarioResources, autoscaling and scheduling
Answer

Situation read → The pod is OOMKilled although -Xmx is 2g and the limit is 2.5g.

What I'd do →

  1. Remember JVM memory includes metaspace, thread stacks, direct buffers and code cache
  2. Set -XX:MaxRAMPercentage=70 instead of a fixed Xmx
  3. Set the limit with 30% headroom
  4. Check usage with kubectl top and JVM NMT
  5. Use kubectl describe pod to confirm Reason: OOMKilled, exit code 137

Why → Container limits include all process memory, not just heap.

Interview tip → Mention container-aware JVMs since version 10.

All Kubernetes questions Roadmap: Kubernetes core

More on Resources, autoscaling and scheduling