Try
↑ ↓ move↵ openesc close

Interview prep / Percentiles

Junior · Percentiles · System design interview question

Your dashboard shows a p99 of 2 seconds for the last minute, but the service handled only 40 requests in that minute. How much should you trust it?

Sketch your own answer first, then compare it with the one below.

A strong answer

Not much. With 40 requests, 1 percent is 0.4 of a request. Using the nearest-rank definition, the p99 is the 40th value in sorted order, which is the slowest request in the window. The "p99" is really the maximum.

That makes it jumpy. One request that hit a cold cache or a garbage collection pause turns a p99 of 40 ms into 2 seconds, and the next minute it falls back with no change in the service. Someone reading the chart sees a spike that says more about a single unlucky request than about the system.

The cure is to see more requests before you read a tail percentile. Widen the window to five or fifteen minutes. Merge the histograms from all hosts before computing it, instead of reading each host alone. Print the request count under the number so a reader can judge it. If an alert must stay on a quiet service, base it on a count of slow requests over a longer window, because a handful of slow requests is a clearer signal than one percentile of a thin minute.

Sources

Learn it by running it

The percentiles and why averages lie lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms