skip to content

A JVM service's p99 doubled after a release that also moved its pods to a new Kubernetes node pool; how do you find which change caused it?

level: seniorimportance: should knowfreq 50%

answer

  1. two suspects, one experiment
  2. list every change, not just code
  3. old build on the new nodes
  4. what the JVM chose at startup
  5. processor count, collector, throttling

basics

~20 s

List every change, not only the code: dependencies, base image and JDK, flags, CPU limits, node hardware. Then separate them by experiment, such as the old build on the new nodes, and compare what the JVM chose at startup on each side.

solid answer

~40 s

I write down everything that changed: code and dependency bumps, the base image (and with it perhaps the JDK), JVM flags, the pod's CPU and memory settings, and the new pool's CPU model, core count and neighbours. Then I break the confound by experiment: the old build on the new pool, or the new build on the old pool, at the same load. On each side I record what the JVM decided at startup, with `jcmd <pid> VM.version` for the exact JDK and `jcmd <pid> VM.flags` for the collector and ergonomic values, because a different processor count changes GC and compiler thread counts and, below two processors, swaps G1 for Serial. And I check whether the new pods are CPU-throttled, which stretches tails while average CPU looks fine.

code

bash · 4 lines
bash
# run on one old-pool pod and one new-pool pod, then diff the outputs
jcmd <pid> VM.version
jcmd <pid> VM.flags
jcmd <pid> VM.info > /tmp/vm-info-$(hostname).txt

go deeper

for a junior

Recall that a deploy can change more than code: the image, the JDK, the flags and the machine underneath can all change, and each can affect latency.

for a middle

Explain how to list the changes and how jcmd's VM.version and VM.flags show what JDK is running and which collector and ergonomic values it chose.

for a senior

Demonstrate breaking a confound by experiment, crossing build and node pool at the same load, and naming the platform mechanisms (throttling, processor count, slower cores) that leave the code innocent.

for a principal

Argue for not bundling a platform move with a release, for pinning JVM options explicitly rather than relying on ergonomics, and for recording the JVM's startup decisions on every instance.

## Two changes, one regression The release went out on the same day the pods moved to a new Kubernetes node pool, and the p99 doubled. Either change can stretch a tail on its own, and so can the interaction between them. The trap is **attribution by memory**: the release is the change everyone remembers, so it gets the blame, the code is rolled back, and the platform cause survives to bite the next release. The goal is to make each change testable on its own. ## Inventory every change A release and a move are each a bundle of smaller changes. Write all of them down, with timestamps: - **Code**: the diff, new queries, new calls to downstreams, changed caching. - **Dependencies**: library bumps, a new HTTP client or JDBC driver version, a changed serialization library. - **Base image**: a refreshed image can bring a different **JDK release**, a different C library, or different default JVM options in the image's start script. - **JVM flags and settings**: anything in the launch command, environment variables that carry options, heap percentages. - **Pod resources**: CPU requests and limits, memory limit. - **Nodes**: CPU model and per-core speed, core count, kernel version, what else runs on the node, the network path to the downstreams. - **Traffic**: did the move change which zone or load balancer serves which clients? ## Break the confound Attribution needs an experiment, not a timeline: 1. **Cross the two variables.** Run the previous build on the new pool and the new build on the old pool, at the same load. Whichever combination is slow names the change. 2. **Use a canary when you cannot cross.** Route a slice of traffic to the new build on the old pool, keep a baseline beside it, and compare the same percentile at the same time. 3. **Revert one variable at a time.** Reverting both at once restores the p99 and teaches nothing. 4. **Hold load and mix constant** across every comparison, or the experiment measures traffic. ## What the JVM decided on the new nodes The same image does not guarantee the same JVM behaviour. HotSpot makes **ergonomic** choices at startup from what it sees: the processor count (from the container's CPU quota and the CPU affinity) and the memory (the container's limit when one is set). Those choices set GC thread counts, compiler thread counts, default heap sizes and even the collector: on JDK 25, a JVM with **fewer than two active processors or under about 1.8 GB of memory** is not treated as a server-class machine and gets the **Serial** collector instead of G1, whose single-threaded stop-the-world collections stretch tails. | Question | Evidence | |---|---| | Which JDK is running? | `jcmd <pid> VM.version` | | Which collector and ergonomic values did it pick? | `jcmd <pid> VM.flags` (flags set on the command line or ergonomically) | | What processor count and memory limit does it see? | `jcmd <pid> VM.info`, JFR `jdk.ContainerConfiguration` | | Is it being throttled? | JFR `jdk.ContainerCPUThrottling`, the cgroup's throttling counters | Compare these between an old-pool pod and a new-pool pod; any difference is a lead to test, and what the JVM believes about CPUs and memory inside a container is a subject in its own right. ## CPU time you did not get - **Throttling**: a CPU limit enforced per scheduling period can stall a busy JVM mid-request even though its average usage is far below the limit; the mechanism is covered with Kubernetes CPU throttling. - **Slower cores**: the same CPU limit on slower cores buys less work per period, so CPU-bound requests take longer. - **Neighbours**: co-located workloads compete for caches, memory bandwidth and the network. - **Thread pools sized from a processor count** that differs on the new nodes change concurrency and queueing. ## Confirming the attribution The attribution stands when the slow combination is reproducible, the fast one is not, and the mechanism you suspect (a different collector, throttling, a slower dependency path) is visible in the evidence on the slow side and absent on the fast side. Only then is a fix chosen, and it is proved with the same comparison.

  • Why could the same image pick a different collector on the new pool?
    HotSpot selects G1 ergonomically only on what it treats as a server-class machine; with fewer than two active processors, or under about 1.8 GB of memory, JDK 25 falls back to Serial. In a container the processor count comes from the CPU quota and affinity and the memory from the limit, so a smaller pod shape changes the choice. `jcmd <pid> VM.flags` shows which collector was selected.
  • The old build is just as slow on the new pool, with identical flags and no throttling. Now what?
    The release is cleared and the platform is the suspect. Compare per-core speed (the same CPU limit on slower cores does less work), co-located workloads, kernel and node configuration, and the network path to the downstreams. Keep a pod on each pool side by side and move one variable at a time.

  • Blames the code because the release is the change everyone remembers.
  • Assumes the JVM makes the same ergonomic choices on any node.
  • Reads average CPU usage as proof the pod gets enough CPU.
  • Reverts both changes at once and calls the cause found.
  • Assumes a refreshed base image keeps the same JDK release.