Scrivio Interview library

JVM tuning

16 questions in 5 subtopics.

Heap sizing

ConceptFoundations7 min read
What do -Xms and -Xmx do, and why do many teams set them to the same value for server applications? What is the container-friendly alternative?
ScenarioIntermediate8 min read
How do you choose the heap size for a new service before production? Describe a method based on measurement rather than guesswork.
ScenarioAdvanced7 min read
Your cloud bill shows JVM pods requesting 4 GiB of memory while median RSS is 1.5 GiB. How would you run a right-sizing program across 500 services without causing OOM incidents?

JVM flags

ConceptFoundations6 min read
How do you see the effective value of every JVM flag, both for a given command line and for a JVM that is already running?
DebuggingIntermediate7 min read
After upgrading from JDK 11 to JDK 21, a service fails at startup with an Unrecognized VM option error for an old GC-related flag it has used for years. What happened, what do you do, and how do you prevent this?
DesignAdvanced7 min read
Your platform team ships a base container image used by all Java services. Decide which JVM options go in the base image for everyone and which stay per service, and explain how you deliver them.

Container awareness

ConceptFoundations6 min read
How does a modern JVM detect container limits? If you run a JVM without -Xmx in a pod with a 1 GiB memory limit and 2 CPU limit, what heap and processor count will it use?
DebuggingIntermediate7 min read
On a host using cgroup v2, a service built on an old JDK 8 update reports Runtime.availableProcessors() equal to the node's 64 cores and sizes its heap from the node's memory instead of the pod limits. Explain the impact and fix.
DesignAdvanced7 min read
Write the container sizing policy for JVM services in your company: CPU requests and limits, memory, and heap percentage. Explain the reasoning behind each rule.
LeadershipPrincipal7 min read
Before JDK 10 the JVM ignored container limits; later it learned cgroup v1 and then cgroup v2, and the way CPU shares are used changed in later releases. What does this history teach about relying on runtime auto-detection in your infrastructure over the next decade?

Ergonomics

ConceptFoundations6 min read
What is JVM ergonomics? List decisions it makes when you start a JVM with no tuning flags.
DebuggingIntermediate6 min read
The same service image runs on 1 CPU / 1.5 GiB pods in staging and 4 CPU / 8 GiB pods in production. Engineers see different GC logs, thread counts and performance profiles between the two. Explain what differs and what you would change.
LeadershipPrincipal5 min read
OpenJDK has ongoing work toward collectors that size the heap automatically from load and available memory. Should your organisation plan to move from explicit per-service heap settings to self-sizing JVMs over the coming years? How would you decide?

Tuning methodology

ConceptFoundations6 min read
Why is it a bad idea to copy a list of JVM tuning flags from a blog post into your service?
ScenarioIntermediate7 min read
A JVM service misses its p99 latency SLO. Describe your tuning methodology from start to finish.
LeadershipPrincipal6 min read
A long-lived service carries 40 JVM flags added over a decade, many copied from old articles. Over the long term, what stance should the organisation take on JVM tuning, and how do you change the culture?