Topic 100 / Core
Latency, throughput and tail latency
Chapter 6.5 · Performance Analysis
What and why
A single latency number (→ 19) describes one operation; a running system produces a distribution of latencies across many requests, and summarizing that distribution with just the mean hides exactly the requests users feel worst. Latency is the time for one request; throughput is requests completed per unit time; tail latency is the latency of the slowest fraction (commonly p95, p99, p999). Tail latency amplification is what happens when a single user-facing request depends on many backend calls: the chance that at least one of them is slow grows fast with how many there are. Builds on: → 19 (latency numbers every engineer should know).
Diagram
| Percentile | Means | Why it matters |
|---|---|---|
| p50 (median) | half of requests are faster than this | describes a "typical" request, nobody's actual worst case |
| p90 | 90% are faster, 10% are slower | the first percentile where "slow" requests start showing up |
| p99 | 99% are faster, 1% are slower | at scale, 1-in-100 happens constantly, to real users |
| p999 | 99.9% faster, 1-in-1,000 slower | what a very-high-fan-out request amplifies into "almost everyone" |
How it works
- Collect every request's latency over a window, sort them, and read off percentiles by rank — the p-th percentile is the value at rank ⌈p/100 × N⌉ in the sorted list.
- The mean is pulled toward the bulk of fast requests and hides a small number of very slow ones; a distribution can have a low mean and a terrible p99 at the same time — this is why "average latency" alone is not an acceptable report.
- Throughput and latency interact: as a system approaches capacity, queueing (→ 101) makes latency rise sharply well before throughput visibly drops — latency degrades first, as an early warning.
- Tail latency amplification: if a single backend call is slow with probability p, and a user-facing request fans out to n independent such calls, the probability at least one is slow is 1 − (1 − p)ⁿ — this grows much faster than n × p for even modest n.
- Reducing tail latency usually means attacking the specific slow path (a pause, a lock, a slow dependency, a retry) rather than the "average" case — median and tail latency often have different causes entirely.
Practical example
(numbers illustrative). A backend call is slow (over 100 ms) 1% of the time. A user-facing request fans out to 10 such calls in parallel. Probability at least one is slow = 1 − 0.99¹⁰ ≈ 1 − 0.9044 ≈ 9.6% — nearly 10× the single-call rate. At a fan-out of 100 calls, probability at least one is slow = 1 − 0.99¹⁰⁰ ≈ 1 − 0.3660 ≈ 63.4% — a "1% problem" has become a coin flip for most requests.
When to use it
- Use percentiles (p50/p90/p99 at minimum) for every latency report and every SLO (→ 203) — never a bare average.
- Use tail latency amplification reasoning specifically when designing any fan-out request (→ 99) or any request with multiple sequential or parallel dependencies.
- Avoid reporting a single aggregate number for a system with high fan-out — it will look fine while users experience something else.
- Failure scenarios: a dashboard showing a healthy average latency while p99 is far outside target for a meaningful fraction of real users; a newly added dependency that's individually "99% fast" quietly dragging down the composite request's effective success rate through fan-out amplification; measuring percentiles over too short or too skewed a window to be representative.
- Simpler alternative: for a low-fan-out, low-traffic internal tool, mean latency with a rough sense of "worst case I've seen" may be enough — percentile rigor earns its cost once traffic or fan-out is high enough that the tail is routinely hit.
Practice
(numeric drills — 20 min; compute by hand, then verify).
- A single backend call is slow with probability 1%. A request fans out to 10 such calls in parallel, independently. What is the probability at least one call is slow?
- Same per-call probability, fan-out = 100. What is the probability at least one call is slow?
- A request makes 5 sequential calls (not parallel), each individually meeting its own p99 (99% ≤ its latency target) independently. What is the probability all 5 meet the target?
- Given this sorted list of 20 latencies in ms — 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 8, 9, 10, 12, 15, 20, 30, 80 — find p50 (rank ⌈0.50×20⌉), p90 (rank ⌈0.90×20⌉), and p99 (rank ⌈0.99×20⌉) by nearest-rank.
- Using drill 4's result, by what multiple does p99 exceed p50?
Answer key: (1) 1 − 0.99¹⁰ ≈ 9.6%. (2) 1 − 0.99¹⁰⁰ ≈ 63.4%. (3) 0.99⁵ ≈ 95.1% — already below the 99% target for any single call, showing sequential composition amplifies too. (4) rank ⌈10⌉ = 10th value → p50 = 6 ms; rank ⌈18⌉ = 18th value → p90 = 20 ms; rank ⌈19.8⌉ = 20th value → p99 = 80 ms. (5) 80 ÷ 6 ≈ 13.3×.
Done when all five answers match the key.
Key takeaway
Averages hide the tail; percentiles reveal it, and fan-out turns a small per-call failure rate into a large composite one through 1 − (1 − p)ⁿ. Done when you can: compute p50/p90/p99 from a raw latency list and compute tail amplification for a given fan-out. Used next in → 101 (Little's Law and queueing, why latency rises sharply near capacity), → 203 (SLIs/SLOs, where percentiles become targets).
References
None — this topic makes no external claims.
Source directory