Tail Latency and Fan-Out Amplification
Why a request that touches a hundred machines is slow even when every machine is fast, and what hedging buys — derived from the distribution of a maximum.
The maximum is the parent
Let a parent request issue sub-requests with latencies , independent and identically distributed with CDF , and let the parent complete when the last child does. Then the parent latency has
where is the tail function.
To achieve it is necessary and sufficient that each child satisfies — that is, must be the child's quantile. For :
So a hundred-way fan-out turns a p99 target on the parent into a p99.99 target on each child.
Key idea
Fan-out does not make any individual service slower. It changes which quantile of that service the user experiences. A service optimised to a p99 target is, under 100-way fan-out, being consumed at its p99.99 — a part of the distribution nobody measured, nobody tuned, and which is usually dominated by effects invisible at p99: garbage collection, a cold cache, a retry, a kernel scheduling hiccup.
What hedging buys
The standard countermeasure is to send a second copy of a sub-request if the first has not returned by some deadline , and take whichever answers first.
Let be the latency of one attempt, with tail . Issue a second, independent attempt at time if the first is still outstanding, and let be the time until the first response. Then for ,
and for , .
Assumptions
- The two attempts are independent — different replica, different host, no shared bottleneck. A hedge routed to the same overloaded machine buys nothing, which is the common failure mode.
- Issuing the hedge does not slow the original. At low hedge rates this is nearly true; at high rates it is false, and the cost proposition below is what bounds the damage.
Take to be the p95 of . Then for beyond the tail is the product of two small numbers rather than one. If decays exponentially with scale , so , the hedged tail is — the decay rate has doubled.
If the hedge fires at delay , the expected number of attempts per logical request is
so hedging at the p95 costs at most 5% additional load, and at the p99 at most 1%.
Key idea
Hedging is unusually cheap because it is conditional: it only duplicates the requests that are already slow, and by construction those are rare. Five percent extra capacity to square the tail is one of the best trades available in a serving system — provided the hedge lands somewhere genuinely independent, and provided the system has the 5% to spare, which by the utilisation wall it will only have if it is not already near saturation.
Reading the numbers
Two consequences are worth carrying around.
- Measure the quantile your architecture actually consumes. If a request fans out ways, instrument the child at , not at . For and a p99 parent target that is p99.99 — which needs on the order of samples to estimate at all, a measurement problem in its own right.
- Reducing fan-out is a latency optimisation. Halving the number of shards a query touches moves the consumed quantile from to , which is a strictly easier target. This is a real argument for larger shards, and it trades against the memory and pooling arguments elsewhere in this field.
What this does not say
This page treats the children as independent draws from a fixed distribution. It does not model the case where the slow child is slow because of the parent's own load — a self-inflicted straggler. Nor does it cover the case where partial results are acceptable: if the parent can answer with 95 of 100 shards, the relevant order statistic is rather than the maximum, and the fan-out penalty largely disappears. Designing for partial results is the strongest available defence against tail amplification, and it is an application-level decision rather than an infrastructure one.
References
- PaperJ. Dean, L. A. Barroso (2013). The Tail at ScaleSource of the hedged-request and tied-request techniques discussed here.
- PaperA. Vulimiri, P. B. Godfrey, R. Mittal, J. Sherry, S. Ratnasamy, S. Shenker (2013). Low Latency via RedundancyAnalyses when duplicating a request reduces latency and when it backfires through added load.
These works are cited as sources to read, not reproduced. All exposition, examples and problems on this site are written independently; where an argument is standard, the citation points to a canonical treatment.
Results stated on this page
- PropositionThe distribution of the slowest of n callsproof includedWith independent sub-requests the parent latency is the maximum, whose CDF is the per-call CDF raised to the n-th power.
- CorollaryFan-out shifts which quantile you must controlproof includedTo keep the parent's p-quantile at t, each of n independent children needs its p^(1/n) quantile at t, which for n = 100 and p = 0.99 is the child's p99.99.
- PropositionA hedged request truncates the tail at the hedge delayproof includedIssuing a duplicate after d seconds and taking the first reply bounds the tail by d plus an independent copy of the latency, so the tail beyond d decays like the square of the original.
- PropositionThe extra load a hedge createsproof includedHedging at the p-quantile adds at most a 1−p fraction of extra requests, so hedging at p95 costs 5% more capacity.