Try
↑ ↓ move↵ openesc close
In this lesson · topic 5 of 7
  1. 1. When a retry makes it worse
  2. 2. Backoff, jitter, budgets and breakers
  3. 3. Break a dependency and compare six retry policies
  4. 4. Jitter spreads retries, only budgets and breakers cap them
  5. 5. Hedging the slow tail
  6. 6. Deadlines down the chain, keys across the retry
  7. 7. Sizing the retry safety net

Topic 5

Hedging the slow tail

6 min read

Everything so far retries after a failure. A hedged request does something different. It never waits for a failure. It duplicates a request that is merely slow, and it is aimed at latency and not at errors.

Why the tail matters

Take a page that needs answers from 100 servers in parallel. Each server answers in 1 ms at the median, but 1 percent of its answers take a full second. The page is as slow as its slowest part. The chance that all 100 are fast is 0.99 to the power of 100, about 37 percent. So about 63 percent of page loads wait on at least one slow answer. A slow tail on one server becomes the common case for the caller.

Dean and Barroso made this point in The Tail at Scale. At fan-out, the 99th percentile of a single server is what most users get.

The hedge

Send the request to one replica. If no answer arrives within a short delay, send the same request to a second replica. Use whichever response comes first, then cancel the other.

The delay is chosen from the latency distribution. Set it at the 95th percentile: the first request is slow only 5 percent of the time, so only about 5 percent of requests ever send a second copy. The extra load is about 5 percent.

The paper reports a benchmark where a request fanned out to 1,000 reads from a storage system. Hedging after the 95th percentile delay cut the 99.9th percentile latency from 1,800 ms to 74 ms, with about 2 percent more requests. That is a large win for a small cost, and it works because slowness is usually local to one machine: a garbage collection pause, a busy disk, a noisy neighbour. A second replica is unlikely to be slow in the same moment.

Predict first

Requests normally take 20 ms, and the 95th percentile is 60 ms. You hedge any request still unanswered after 60 ms. About how much extra load does hedging add?

How it differs from a retry

Retry Hedge
Starts after A failure or a full timeout A short delay, well before the timeout
Original request Abandoned Left running
Aimed at Errors Slow answers
Extra load Grows with the failure rate About the share of requests past the delay

That last row is the safety question. A retry adds the most load when the dependency fails most. A hedge adds load when requests are slow, and an overloaded dependency makes every request slow. If the 95th percentile rises with load, more requests pass the hedge delay, more copies are sent, and the extra load feeds the slowness. The hedge becomes a retry storm that started before any request failed.

Keeping it safe

  • Only idempotent calls. Two copies may both run. For a read this costs nothing. For a charge it is a duplicate.
  • Cap the load. Run hedges through the same kind of budget as retries, so hedges are suppressed when too many are in flight.
  • Set the delay from live data, not a constant. A fixed 60 ms is wrong the moment the service changes speed.
  • Stop hedging under overload. If a breaker is open or queue delay is high, a second copy only makes things worse.
  • Cancel the loser. The cancel should reach the server, or the copy still runs to completion.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms