Tail latency and hedged requests
Analyze fan-out latency, conditional hedging, and the resource amplification hidden behind faster individual responses.
On this page
The question for today
What you’ll understand
- Derive how required fan-out amplifies a leaf latency tail.
- Estimate hedge launch rate from the measured survival function.
- Explain why correlated overload can erase the benefit of duplicate requests.
A request that waits for many parallel children experiences the slowest required child. Improving the median child can leave that parent nearly unchanged if a small population encounters contention, cold state, or a shared slowdown. Hedging sends an additional copy after a delay and accepts an eligible first result. It can reduce waiting under suitable conditions, but it spends capacity and introduces cancellation and correctness obligations. We will calculate these effects under explicit simplifying assumptions, then replace those assumptions with measurements.
A parent inherits the slowest required child
Let F(t) be the probability that a child finishes within time t. If an operation requires m independent, identically distributed children launched together, the parent finishes by t only if every child does. The result explains why an apparently small child tail can become common at the parent. Independence is a strong assumption: shared storage, network paths, or synchronized garbage collection can alter the joint distribution. Use traces to retain those relationships rather than independently shuffling child samples and calling the result a production forecast.
Measure latency at the user's boundary, including queueing, connection setup, admission, and retries. Partition results by operation, payload, cache state, and relevant tenant cohort. Preserve timeout and cancellation counts: omitting incomplete requests makes the tail look artificially healthy. A load generator that waits for each response before issuing the next request can reduce offered load exactly when the service slows. Use a controlled arrival schedule and report the offered and completed workloads separately when studying overload behavior.
Hedge only while a useful deadline remains
For an eligible read, launch a second copy at delay h only if the first is unfinished. The client accepts a valid result and cancels remaining work where possible. Under a simple model, hedge launch probability equals the original request's survival probability at h. That is an attempt-count estimate, not a CPU estimate: the abandoned original may already have consumed substantial work and cancellation may arrive after completion. Trace both copies with a shared operation identifier and separate attempt identifiers so extra resource use is visible.
Eligibility needs semantic review. A read can still trigger side effects such as billing, cache fills, or external requests. Writes require a proven deduplication or transaction boundary before duplication is safe. Bound hedge count, use an alternate failure domain when appropriate, and disable hedges under overload unless experiments demonstrate a benefit within the resource budget. An immediate duplicate to the same saturated dependency may worsen the tail for every caller. Evaluate user latency together with useful throughput, queue growth, and resources per completed operation.
Distinguish request diversity from common slowdown
When two independent copies start simultaneously, the event that both exceed a threshold has probability equal to the product of their tail probabilities. A delayed hedge has a shorter remaining window, so its expression differs. If a common outage or shared queue affects both copies, multiplying marginal probabilities is invalid. Estimate conditional tail behavior from experiments that preserve placement and load. A representative test should include the recovery interval, because a surge of duplicated work can delay clearing the backlog even after the initiating slowdown ends.
The queue lab provides a deliberately simpler warning. Raise arrival rate toward service rate and inspect the separately labeled M/M/1 mean residence time under its assumptions. Play the deterministic fluid backlog to see surplus arrivals accumulate. Neither readout is a hedging simulator or a percentile estimate, and the lab cannot represent correlated request durations. Use it to explain why spending spare service capacity on hedges has a limit, then return to measured latency distributions for an actual policy decision.
Work it through
A modest leaf tail becomes a common parent delay
Each of 50 required independent children finishes by 100 ms with probability 0.99. Separately, an entirely hedge-eligible measured single-request workload has 2% of originals unfinished at a chosen hedge delay. Launch exactly one hedge for those unfinished originals and allow no other retries. Calculate parent tail probability and expected started attempts.
All 50 children finish by 100 ms with probability 0.99⁵⁰ ≈ 0.605006.
The parent therefore exceeds 100 ms with probability 1 − 0.605006 ≈ 0.394994, or 39.50%.
For the separate hedge policy, expected started attempts are 1 + 0.02 = 1.02 per operation. At 10,000 original operations/s, this means about 200 hedge launches/s.
The parent tail is far larger than 1%. A 2% hedge launch rate adds 2% started attempts, but resource overhead and actual latency improvement still require measurements.
The living notebook
Explore the model
Interactive lab · queue
Spare capacity is a hedge budget
Adjust arrival rate λ and service rate μ. The animation shows fluid backlog max(0, 4 + (λ − μ)t); the M/M/1 mean residence readout is a separate assumed stochastic model, not a tail percentile.
- Fluid backlog
- 4
- Net rate · λ − μ
- −1 /s
- M/M/1 mean residence
- 1 s
Fluid backlog starts at 4 and follows max(0, 4 + (λ − μ)t). The separate M/M/1 residence-time formula assumes Poisson arrivals, exponential service and λ < μ. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forExtra copies consume finite capacity; this lab illustrates overload pressure rather than predicting hedge latency.
Pause & reason
Check your understanding
Your turn
Try it yourself
A parent waits for 20 independent identical children, each with 95% probability of finishing by a threshold. A separate hedge policy launches an extra copy for 5% of originals. Compute the parent threshold exceedance probability and the extra launches at 4,000 originals/s.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
The parent succeeds only when all children meet the threshold. Count hedge launches from original operation rate.
Compare with the solution
Parent exceedance is 1 − 0.95²⁰ ≈ 0.641514, or 64.15%. Hedge launches are 0.05 × 4,000 = 200/s, making 4,200 started attempts/s. These separate calculations do not predict whether hedging improves the fan-out workload; correlation, cancellation, service cost, and deadlines remain unspecified.
Keep the idea
Take it with you
- Required fan-out can magnify a small independent leaf tail.
- Hedge launch counts do not directly equal resource overhead.
- Measure correlation and overload behavior before spending capacity on duplicates.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.