Scrivio Interview library
DebuggingFoundations6 min read · updated 13 November 2026

A service runs 40 pods, and each pod exports its own p99 request latency as a gauge. The fleet dashboard averages these gauges and shows a p99 of 50 ms, while user complaints and traces show many requests taking 900 ms.

Why is the dashboard wrong, and how should latency be stored so fleet-wide percentiles are correct?

Percentiles cannot be averaged or summed: the average of 40 per-pod p99 values is not the fleet p99, and a few slow pods can hold most of the slow requests while barely moving the average. Pre-computed quantiles from client-side summaries cannot be merged either. We store distributions instead, histograms with fixed buckets whose counts can be summed across pods and time, or mergeable sketches, then compute the fleet p99 by summing bucket rates before histogram_quantile, and alert on the share of requests slower than the SLO, which bucket counts give exactly.

Why this question is asked

A dashboard that says everything is fine while users suffer is worse than no dashboard, because it sends the team looking in the wrong place. This one is a classic: each pod reports its own p99, and the dashboard averages them. Interviewers ask about it because it tests real understanding of what a percentile is and how monitoring systems store latency, which every backend engineer touches. In this answer, we will recap percentiles, show with numbers why averaging them fails, see why client-side summaries cannot be fixed by better math, switch to histograms and sketches, write the correct Prometheus query, and finish with an exact SLO-based alert.

1A Quick Recap of Percentiles

The p99 latency is the value below which 99 percent of requests fall. If a service handled 100,000 requests in a minute, the p99 is roughly the 99,000th fastest one. It tells us about the slow tail that the average hides. The key property is that a percentile is a fact about the whole set of requests: to know the fleet p99, we need to know about every request in the fleet, or at least how many fell into each latency range.

2Why Averaging Per-Pod p99 Values Is Wrong

Suppose 39 pods are healthy, each with a p99 of 30 ms, and one pod sits on a bad node with a p99 of 830 ms. The dashboard averages: (39 x 30 + 830) / 40 = 50 ms, which looks fine. But the real fleet tail is very different. If each pod serves 1,000 requests a minute, the bad pod's slowest requests, and probably most of its 1,000, are far slower than anything the healthy pods produce, and they make up the fleet's slowest 1 percent. The true fleet p99 is in the hundreds of milliseconds, close to what users and traces report.

Averaging also ignores traffic: a pod that serves 50 requests counts as much as one that serves 5,000. And summing or averaging p99 values over time windows has the same problem. A percentile of a combined set is simply not a function of the percentiles of its parts.

Per-pod p99 vs the fleet
Podsp99 eachRequests per minuteEffect on fleet tail
39 healthy pods30 ms39,000almost none of the slowest 1 percent
1 pod on a bad node830 ms1,000provides most of the slowest 400 requests
Average of p99s50 mslooks healthy, is meaningless
True fleet p99hundreds of ms40,000matches traces and complaints

3Why Client-Side Summaries Cannot Be Merged

Many metrics libraries offer a summary type, where each pod computes quantiles such as p50 and p99 locally over a sliding window and exports only those numbers. That is what the pods do here. Once the per-pod distribution has been reduced to a few quantiles, the information needed to combine pods is gone. No formula turns 40 p99 values into the fleet p99, and the same is true for combining one pod's p99 over 5 minutes into an hour. Summaries are fine for looking at a single instance, but not for fleet-wide or long-range percentiles.

4Storing Distributions: Histograms and Sketches

The fix is to export the distribution rather than a quantile. A histogram with fixed buckets counts how many requests fell at or below each bound, for example 25, 50, 100, 250, 500, 1000 and 2500 ms. Counts are just numbers, so they can be summed across pods and over time windows, and any percentile can be estimated from the combined counts. In Spring Boot with Micrometer, enabling a percentiles histogram for http.server.requests exports these buckets, and service-level objective boundaries can be added so the SLO threshold is an exact bucket.

Mergeable sketches, such as HDR histograms, t-digest and DDSketch, go further: they keep a compact summary of the distribution with bounded relative error, and two sketches can be merged into one that is as good as if all data had gone into one. Some backends store these, and Prometheus native histograms use exponential buckets with a similar effect.

YAML
# application.yml (Spring Boot, Micrometer)
management:
metrics:
distribution:
percentiles-histogram:
http.server.requests: true
slo:
http.server.requests: 100ms,300ms,500ms
# exports http_server_requests_seconds_bucket{le="0.3", ...} counters per pod

5The Correct Fleet p99 Query

With Prometheus-style histograms, we take the rate of each bucket counter per pod, sum the rates across pods while keeping the le label (the bucket bound), and only then compute the quantile. The order matters: summing first combines the distributions, and histogram_quantile then finds the bucket that contains the 99th percentile and interpolates inside it.

Java
# Wrong: average of per-pod quantiles
avg(http_request_p99_seconds) # 0.050
# Right: combine buckets first, then estimate the quantile
histogram_quantile(0.99,
sum by (le) (rate(http_server_requests_seconds_bucket{service="api"}[5m]))) # about 0.8

There is a catch: the result is only as precise as the buckets. If the bounds jump from 250 ms to 1000 ms, a p99 anywhere in between is a linear guess. So we choose bounds densely around the values we care about, especially the SLO threshold.

6Alerting on the Share of Slow Requests

For alerts, a percentile is not even the best signal. If the SLO says requests should take under 300 ms, we can compute exactly what fraction of requests exceeded 300 ms, because 300 ms is a bucket bound: one minus the rate of the le=0.3 bucket divided by the rate of all requests. That number is exact, mergeable and directly tied to the SLO, so it is the standard basis for error-budget and burn-rate alerts.

Java
1 - (
sum(rate(http_server_requests_seconds_bucket{service="api", le="0.3"}[5m]))
/
sum(rate(http_server_requests_seconds_count{service="api"}[5m]))
) # 0.012 -> 1.2 percent of requests slower than 300 ms

7Follow-up questions

Why do summaries exist at all if they cannot be merged?

They give accurate quantiles for one instance without choosing bucket bounds, and they are cheap to query. They are fine when there is only one instance or when we only care about each instance separately. For fleets and long ranges, histograms or sketches are the right choice.

How many histogram buckets should we use?

Enough to be precise near the SLO and the typical latency, usually 10 to 20 bounds, because every bucket is a separate series per label combination and adds to cardinality. Native or exponential histograms reduce this trade-off where the backend supports them.

Is the average latency useful?

It is useful for capacity, since total work is average times rate, but it hides the tail completely, so it should never replace percentiles or the share of slow requests for user experience.

8Conclusion

In this answer, we saw that percentiles cannot be averaged or summed, because a percentile describes the whole set of requests and a few slow pods can hold most of the tail while barely moving the average of p99s. Client-side summaries cannot be merged either. Storing histograms with fixed buckets, or mergeable sketches, lets us sum counts across pods and time, compute the fleet p99 with histogram_quantile after summing bucket rates, choose buckets around the SLO, and alert exactly on the share of requests slower than the threshold.

What to say in the interviewAbout 80 seconds aloud

Open with

The dashboard averages 40 per-pod p99 values, and percentiles cannot be averaged. A p99 describes the whole set of requests, so if 39 pods have a p99 of 30 milliseconds and one pod on a bad node has 830, the average says 50, but that one pod contributes most of the fleet's slowest one percent, so the true fleet p99 is in the hundreds of milliseconds, which matches the traces.

Then, if they want more

The average also ignores how much traffic each pod serves. And because each pod exports a pre-computed quantile from a summary, there is no way to combine them correctly after the fact, across pods or over time. The fix is to store distributions. With Micrometer I would enable the percentiles histogram for http.server.requests, so each pod exports bucket counters.

Counts can be summed, so the fleet p99 is histogram_quantile of 0.99 over the sum by le of the bucket rates: sum first, then quantile. The precision depends on the buckets, so I would put bounds around the SLO threshold, or use native histograms or a sketch like DDSketch where the backend supports it.

For alerting I would use the share of requests slower than the SLO, say 300 milliseconds, which is exact from bucket counts and maps directly to an error budget.

About this answer

Last updated
13 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Why is the dashboard wrong, and how should latency be stored so fleet-wide percentiles...": https://scrivio-interview-library.netlify.app/architecture/storage-and-pipelines/41fd57977f/