After changing a JVM service to fix its p99 regression, how do you prove with before-and-after evidence that the change worked?
answer
- same yardstick on both sides
- same load, mix and hours
- long enough for the rare event
- the blamed mechanism moved too
- nothing else got worse
basics
~20 sMeasure the same percentile from the same histogram at the same load and traffic mix, over a window long enough to contain the events behind the tail, ideally canary beside baseline, and check that the mechanism you blamed moved too.
solid answer
~40 sI compare like with like: the same p99 from the same histogram, at the same request rate and mix, ideally a canary with the fix running beside an untouched baseline so traffic and time of day hit both. The window must contain the rare events behind the tail: several old-generation cycles if GC was the cause, the daily peak if it was queueing. I ship one change at a time, so the credit is unambiguous. And I check the mechanism, not only the outcome: if the diagnosis was long pauses, the pause durations should drop with the p99. If the p99 improved but that evidence did not move, the diagnosis was wrong. Finally I check that p50, throughput and CPU did not pay for it.
go deeper
Recall that a fix must be measured the same way the problem was: same percentile, same metric, similar traffic.
Explain the conditions that make a before-and-after comparison valid: same yardstick, same load and mix, a long enough window, one change at a time, and a check on p50, throughput and CPU.
Show that you tie the outcome to the mechanism: the evidence that named the cause must move with the p99, or the diagnosis is reopened.
Discuss making this routine: canary-and-baseline comparison built into the deploy path, and incident records that keep the before-and-after evidence.
## Why a fix needs proof A fix for a latency regression is a hypothesis too. The p99 can come back for reasons unrelated to the change: traffic dropped, a downstream recovered, a noisy neighbour moved away. If the team credits the change anyway, the real cause stays in production and the next regression starts from a false belief. Proving a fix means showing that **the same measurement, under the same conditions, improved, and that the mechanism the diagnosis blamed moved with it**. ## Same yardstick - **Same percentile from the same metric.** If the regression was a p99 from the server-side request histogram, the proof is the p99 from that same histogram, not a different dashboard, a p95, or an average. - **Same timer location and buckets.** A fix release that also changes instrumentation invalidates the comparison. - **Same breakdown.** If the regression was concentrated on one route or one node pool, prove it there, not only in the fleet-wide number where it may be diluted. ## Same conditions - **Same load and traffic mix.** A quiet hour flatters any change. Compare at similar request rates, with the same routes and payloads. - **Side by side where possible.** A **canary** running the fix next to a **baseline** without it, both taking the same live traffic at the same time, removes time-of-day, traffic and downstream variation from the comparison. - **One change at a time.** Two changes in one deploy leave it unknown which helped, and whether one of them hurt. ## Long enough to contain the cause A tail is made of rare events, so the comparison window must contain enough of them: - If GC pauses were the cause, the window should span several of the collections that produced the outliers, including the old-generation or mixed cycles, not just a run of young collections. - If queueing at peak load was the cause, the window must include the daily peak. - If a downstream was the cause, it must include that downstream's busy period. Enough samples at the percentile matter too: a p99 over a few hundred requests rests on a handful of slow ones. ## The mechanism must move too The strongest proof ties the outcome to the cause. Whatever evidence named the cause should change in the expected direction: | Diagnosed cause | Evidence that should change with the p99 | |---|---| | Long GC pauses | pause durations and counts in the GC log | | Slow safepoints | reaching-safepoint times in the safepoint log | | CPU throttling | the container's throttled time and periods | | Lock contention | monitor-blocked and park events in a JFR recording | | A slow downstream | that dependency's client-side latency | If the p99 improved but the blamed evidence did not move, the diagnosis was probably wrong and the improvement came from somewhere else. Keep the investigation open. ## Nothing else got worse A fix that buys tail latency with something else is a trade, not a fix, and the trade should be visible: - p50 and throughput at the same load; - CPU usage and memory footprint per instance; - error rate and timeouts. ## A before-and-after checklist 1. Record the baseline: the exact metric, percentile, breakdown, load and window. 2. Ship one change, ideally as a canary beside an untouched baseline. 3. Run long enough to include the rare events behind the tail and the busiest period. 4. Compare the same percentile, the same breakdown, at the same load. 5. Confirm the blamed mechanism moved in the evidence that diagnosed it. 6. Check p50, throughput, CPU, memory and errors for a hidden cost. 7. Keep the before-and-after evidence with the incident record, so the next regression starts from facts.
- Why is a side-by-side canary better than comparing yesterday with today?Traffic volume, mix and downstream behaviour differ between days, and any of them moves a p99. A canary and a baseline taking the same traffic at the same time see the same conditions, so the difference between them is the change. It also limits the damage if the fix makes things worse.
- The p99 recovered, but the GC pause durations you blamed did not change. What do you conclude?The fix did not work for the reason you think. Something else moved: traffic, a downstream, a side effect of the deploy. Keep the regression open and revisit the evidence that should have discriminated, because the real cause can come back.
It is like judging a diet: you weigh yourself on the same scale, at the same time of day, for several weeks, and you check that the change came from the diet rather than from a week of illness.
- Declares the fix proven after ten quiet minutes.
- Ships three tuning changes together and credits the expected one.
- Compares the new p99 against a different percentile or dashboard.
- Checks only the p99, not the evidence behind the diagnosis.
- Ignores throughput and CPU once the tail looks better.