Tail latency: why P95 and P99 decide your timeout
An API can report a 40 ms average and still be unusable. If one request in twenty takes 800 ms, every page that fans out to ten endpoints will feel it, because the slowest response sets the page time. That is the tail, and it is where capacity plans and timeouts are decided.
What a percentile means in practice
P99 = 600 ms means 99 percent of requests finish within 600 ms and one percent do not. It does not say how far beyond 600 ms that one percent goes. A system with P99 of 600 ms and a maximum of 620 ms behaves very differently from one with the same P99 and a maximum of 30 seconds. Always look at the maximum and at the shape between P99 and P99.9 before writing a timeout.
Percentiles also do not average. You cannot take the P95 of each of five services and average them to get the P95 of the composed call. Fan-out makes this worse: if a request needs ten independent calls and each has a one percent chance of being slow, the chance that at least one is slow is about 9.6 percent.
Reading the three percentiles together
| Percentile | Typical value | What it tells you | Where it is used |
|---|---|---|---|
| P50 | 120 ms | Steady-state experience | Capacity baseline |
| P95 | 250 ms | Behaviour during peaks | Worker sizing, alerts |
| P99 | 600 ms | Worst tolerated normal case | Client and server timeouts |
| Max | 4,000 ms | Queueing or GC events | Retry and buffer design |
Turning percentiles into concurrency
Because Little's Law multiplies rate by latency, a change in a tail percentile has a direct capacity cost. At 500 requests per second, moving P95 from 250 ms to 400 ms raises required concurrency from 125 to 200 — 60 percent more worker slots for the same traffic. This is why latency regressions are capacity incidents even when the error rate is flat.
Track the ratio between P50 and P99 as a health signal. A ratio under four is calm; a ratio above ten usually means one dependency, lock or garbage collection pause is dominating the tail, and no amount of extra instances will hide it.
Setting the timeout from the tail
A timeout below P99 converts healthy-but-slow requests into errors and, worse, into retries. A timeout far above P99 lets a stuck connection hold a worker for seconds. The usual compromise is one and a half to two times P99, with a separate, shorter deadline for internal calls so a slow dependency cannot consume the whole budget.
Finally, measure percentiles per endpoint, not only globally. A single hot endpoint with a heavy tail can sit invisible behind a healthy aggregate, and that endpoint is usually the one customers notice.
Where the tail comes from
Tails are rarely random. In most systems a small number of causes explain most of the slow requests: a cache miss that falls through to a slow database, a garbage collection pause, a lock held by a background job, a retried request that now waits twice, or one tenant sending a query shape nobody else sends. Instrumenting the slowest one percent and grouping it by cause is usually more valuable than another dashboard of averages.
A useful practice is to record, for each slow request, what it was waiting on. When the top cause accounts for more than half of the tail, you have a single fix rather than a capacity problem. When the tail is spread evenly across many causes, extra instances genuinely help, because no single dependency is the bottleneck.
- Sample the slowest requests with their dependency timings attached.
- Compare the tail across tenants and endpoints, not only in aggregate.
- Treat a rising P99 with a flat P50 as a dependency signal, not a load signal.
Open the calculators and put these numbers to work on your own API.
Open API BenchFrequently asked questions
Why not just use the average latency?
The average is dominated by the fast majority and hides how bad the slow minority is. A single tail request can decide a page load time because the slowest dependency gates the result.
How many samples do I need for a trustworthy P99?
At least a few hundred samples in the window you care about; a P99 over 100 samples is essentially the maximum. For low-traffic endpoints, look at P95 or extend the window rather than trusting a noisy P99.
Should the timeout equal P99?
No. Setting it exactly at P99 guarantees that one percent of healthy requests fail. One and a half to two times P99 leaves room for jitter while still bounding worker occupancy.
Sources
- Google SRE Book — Addressing cascading failures
- RFC 9110 — HTTP semantics
- MDN — HTTP response status codes
Related guides
- Capacity planning with Little's LawTurn a target request rate and three latency percentiles into the concurrency, threads and instances an API actually needs.
- Retry storms: how a 1% error becomes 300% loadRetries are new traffic. Calculate the amplification, recognise the cliff, and design retry budgets that fail politely.
- REST vs GraphQL: measuring the payload differenceOver-fetching, under-fetching and query text all show up in the bytes. A practical way to compare the transfer volume of both designs.
- API egress cost: the arithmetic behind the invoiceHow call volume, payload size, compression and cache hit rate become a monthly transfer bill, and where the cheapest savings are.