Why can average latency look fine while users are suffering?
- Posted
- Tags
- reliability, sre, distributed-systems
The average hides the slow tail. p50 shows the typical experience, p99 puts a ceiling on the worst of it, and in a distributed system that slow 1% can take down the services that depend on it.
Latency dashboards almost always show more than one line, and I never really asked why. If the average looks fine, aren't users fine? So I spent today pulling on that thread.
The question I had
Why can the average look fine while users are clearly suffering?
What I found
The average hides the tail
Say 95% of requests come back in 50ms and the other 5% take 5 seconds. The average works out to about 300ms (0.95 × 50 + 0.05 × 5000). On a dashboard, 300ms looks acceptable. But it hides the fact that 1 in every 20 clicks is painfully slow. Nobody actually experiences 300ms. People get either 50ms or 5 seconds.
A percentile tells a different story. p99 is the line where 99% of requests are faster and only the slowest 1% are slower.
| What it measures | What it tells me | When to use it | |
|---|---|---|---|
| Average (mean) | Total latency divided by the number of requests | Blends fast and slow into one number nobody actually sees | Rough capacity and cost estimates |
| p50 (median) | Half of requests are faster than this | The typical experience | Overall health, the "normal day" |
| p99 | 99% of requests are faster than this | How bad it gets for the slowest 1% | User experience, alerts, SLOs |
One slow request per page adds up fast
A single page load in a modern app often fires off dozens of backend requests. If each one has a 1% chance of being slower than p99, the chance that a page hits at least one slow request is 1 − 0.99ⁿ:
- 50 requests per session: about 40% of sessions see at least one p99 delay.
- 100 requests per page: about 63% of pages do.
So "only 1% of requests" can easily mean "most of my users, at some point in their visit".
The slow requests are often the valuable ones
Outliers tend to come from the heavy requests: a big shopping cart checkout, a deep database query, an account with lots of history. The average says the site is fast, while the users doing the most (often the ones bringing in the most business) are the ones hitting the slow tail.
Correcting my first guess
My first thought was that watching p99 means everyone experiences the service at its best. Not quite.
- p50 is the typical experience, not the best one. Half of requests are faster, half are slower.
- p99 is a ceiling on how bad things get. It doesn't promise a great experience, only that 99% of requests are no worse than this.
- The 1% is still real people. At 10 million requests a day, a "good" p99 still leaves 100,000 slow requests. At large scale, teams look at p99.9 or p99.99 for that reason.
The real goal is closing the gap
The two numbers work together. p50 shows the typical experience and overall health. p99 is the threshold to watch, and the goal is to keep it close to p50 so the service feels predictably fast for almost everyone. The distance between them is called tail latency.
- A healthy dashboard: p50, p95, and p99 run roughly parallel and close together. A p50 of 50ms and a p99 of 150ms is a predictable system.
- A misleading dashboard: p50 is a nice 50ms, but p99 spikes to 4 seconds. Overall health looks fine, but the tail is ruining the experience for a slice of users.
When the gap widens, it usually comes from specific bottlenecks rather than general slowness (e.g., GC pauses, resource contention, network retransmits, large jobs).
Why the slow 1% is dangerous
Keeping the gap small isn't only about user experience. In a distributed system, other services have to deal with that slow 1% too, and that's where it turns from "some users wait" into "the whole system falls over".
How the slow 1% cascades
- Exhausted threads and connections. When a downstream service takes 5 seconds instead of 50ms, the caller doesn't fail right away. It holds a thread and a connection open while it waits. As more requests come in, the caller runs out of threads, connections, or memory, and stops accepting new traffic. A slowdown in one small service has now frozen a service that was otherwise fine.
- Retry storms. The usual reaction to a slow call is to time out and retry. If the downstream service is slow because it's overloaded, every retry adds more load, so the slow 1% grows, the p50 climbs too, and the service can be knocked offline. I wrote about this pattern in my thundering herd vs retry storm post.
How to contain it
- Strict timeouts. Never wait forever. If a service normally answers in 50ms, a timeout of around 200ms frees the caller's resources long before they run out.
- Retries with backoff, jitter, and a budget. Retry less, wait longer between tries, add randomness, and cap how many retries are allowed overall. Otherwise the retries cause the storm.
- Circuit breakers. When a downstream service keeps failing or timing out, stop calling it for a short while and return a fallback, like cached data. This gives it room to recover.
- Move work that can wait off the request path. Sending an email or recording an analytics event can go on a queue. If that worker hits a slow patch, the queue gets longer, but the user's request is not affected.
Takeaway
The average tells me almost nothing about how users feel. I watch p50 to see the typical experience and p99 to see how bad it gets, and I try to keep the two close. A small gap protects users, keeps one slow service from pulling down everything that depends on it, and when it widens, it points me straight at the bottleneck to fix. That's the real SRE goal.