advanced32 min studyLesson 72 in Engineering

Tail latency and hedged requests

Analyze fan-out latency, conditional hedging, and the resource amplification hidden behind faster individual responses.

On this page

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.

Pr⁡(Tmax⁡≤t)=F(t)m\Pr(T_{\max}\le t)=F(t)^m
This is the maximum of m independent, identically distributed completion times. The parent has no additional overhead and needs every child; partial-result or correlated systems require a different model.↔ Scroll wide equations horizontally.

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.

E[Nattempts]=1+Pr⁡(T>h)\mathbb{E}[N_{\mathrm{attempts}}]=1+\Pr(T>h)
Every original in this modeled population is eligible, and exactly one hedge is launched at h if and only if the original is unfinished; there are no other retries. This counts started attempts, not full-request resource costs.↔ Scroll wide equations horizontally.

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.

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.

  1. All 50 children finish by 100 ms with probability 0.99⁵⁰ ≈ 0.605006.

  2. The parent therefore exceeds 100 ms with probability 1 − 0.605006 ≈ 0.394994, or 39.50%.

  3. 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 result

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.

Explore the model

Interactive lab

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.

Spare capacity is a hedge budgetFluid backlog starts at 4 and follows max(0, 4 + (λ − μ)t). The separate M/M/1 residence-time formula assumes Poisson arrivals, exponential service and λ < μ. Current readings: Fluid backlog: 4; Net rate · λ − μ: −1 /s; M/M/1 mean residence: 1 s. All parameters are adjustable with the labeled controls below.02.557.51001.534.56Elapsed time · sFluid backlogλ < μ
Fluid backlogCurrent time
Fluid backlog
4
Net rate · λ − μ
−1 /s
M/M/1 mean residence
1 s
t = 0 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.

Check your understanding

When is squaring a single-copy tail probability justified for two simultaneous copies?

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.

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.