Video in progress
Two pods started from the same image behave differently under the same load: one is always slower. What differences do you look for on the JVM and infrastructure side?
First I check that they really are "the same": node type, CPU model, cgroup limits, the ergonomic values the JVM chose. Then random differences inside the JVM (JIT decisions, heap state) and neighboring workloads: CPU steal, throttling, a noisy neighbor. The cause often turns out to be the node or the ergonomics.
📖 Answer
"The same image" doesn't mean the same JVM behavior.
- Ergonomics. The JVM chooses the GC, heap size, thread counts and JIT threads based on the resources it sees.
kubectl exec pod-a -- jcmd 1 VM.flags -all > a.txt
kubectl exec pod-b -- jcmd 1 VM.flags -all > b.txt
diff a.txt b.txt
A typical finding: one pod sees 64 cores on a node with no CPU limit, the other sees 2, so the GC thread counts and ForkJoinPool differ. Or one picked Serial GC.
-
Node differences. In one node pool, different CPU generations (for example ARM and x86, or old and new Intel) mean different intrinsics and AVX levels.
jcmd 1 VM.infoshows the CPU flags. In the cloud, look at CPU steal time (stintop) and the CFS throttling metric. -
Neighbors. Another pod on the same node that is heavy on memory bandwidth, a shared disk (writing the GC log gets slower), contention for the L3 cache. Move the pod to another node and see whether the difference goes with it: the quickest experiment.
-
JIT randomness. The profile depends on the traffic during warm-up. If one pod got unusual traffic at startup, C2 makes different assumptions: different inlining, a different branch order. That can persist for hours. The difference in
jdk.Deoptimizationand compilation statistics in JFR shows it; if the difference disappears after a restart, that was the cause. -
Heap and cache state. One has accumulated more cache, has a fuller Old, more mixed GCs. Compare the GC logs.
-
Traffic distribution. Is the load balancer distributing evenly? Sticky sessions or long-lived HTTP/2/gRPC connections can make the load uneven.
Taking a 60-second JFR recording from both pods at the same time and opening them side by side usually gives the fastest answer.
Sign up to mark studied questions and save your progress.