Skip to content
WebsiteHosting.com

comparison Delivery & performance

Hedged requests, wasted work and latency

A delayed second attempt can shorten the wait for a valid response. Compare the caller’s wait with the work both attempts do, and see why cancellation is no substitute for safe duplication or spare capacity.

Latest recorded source check · P0161

What it means

A hedged request gives a slow request a second chance to finish sooner: if the first attempt is still running after a chosen delay, the caller can start another attempt at the same operation and take the first valid result. The second attempt can shorten the caller’s wait, but while the attempts overlap, the backend is serving two attempts instead of one. Only consider a hedge when the operation is safe to repeat and there is capacity for the extra attempt.

Two quantities matter: how long the caller waits and how long each attempt runs. The caller waits only until a valid result arrives. The backend may still be working after that point.

Try it

Simulation — no requests are sent. Start with the two attempts set to valid, duplicate execution set to safe, and spare capacity set to available. These are assumptions, not checks on a service. Change Loser cancellation assumption from immediate to none. Does the caller wait any longer, or does only the amount of work change?

Hedged requests, wasted work and latency

Explain straggler mitigation against extra backend load

Simulation
Modeled outcome: Hedge wins

Secondary returns the first valid result.

Hedged requests, wasted work and latency: synthetic scenario inputs
Replaces all inputs with the documented starting example and the indicated change. Reset restores the starting example.
Request race versus work consumed

Decision

  1. Outcomehedge-wins
  2. Attempts2
  3. First valid result (ms)180
  4. Work (attempt-ms)260
  5. Gate preventing hedgeNot evaluated / established
Primary stipulated completion0–300 ms
Secondary stipulated completion100–180 ms
First valid completion180 ms
180 ms
0300 ms

Bars show stipulated uncanceled completion times, not observed traffic or cancellation durations. Total work is the evaluated model result; cancellation does not prove that an external effect was prevented.

Evaluated inputs

Required scenario evidence
provided
Primary completion after start
300 ms
Primary result
valid
Hedge launch delay
100 ms
Duplicate execution safety
safe
Spare capacity evidence
available
Secondary completion after launch
80 ms
Secondary result
valid
Loser cancellation assumption
immediate

One redundant attempt, fixed completion times independent of load; cancellation may truncate modeled active time only. Work-ms sums active service duration, not CPU or cost. Capacity and effect safety are stipulated policy gates; no real duplicate operation, side effect or cancellation guarantee.

About this model

The controls set only a local, bounded scenario. The computed branch is not a verdict about a live system. Inputs listed as not evaluated did not participate in this branch after validation.

Reset restores the original inputs. It does not change the open or closed state of help or FAQ answers.

The primary starts at 0 ms and would finish at 300 ms. At 100 ms there is no result yet, so the secondary starts. Its 80 ms duration is measured from its own launch: it returns a valid result at 180 ms, not at 80 ms. Here is the comparison, including what happens if the launch delay is long enough for the primary to finish alone:

Policy in this exampleAttempts startedFirst valid resultTotal active work
100 ms delay, immediate cancellation2Secondary at 180 ms180 + 80 = 260 work-ms
100 ms delay, no cancellation2Secondary at 180 ms300 + 80 = 380 work-ms
300 ms delay, no second launch1Primary at 300 ms300 work-ms

Both 100 ms policies save the caller 120 ms compared with waiting for the primary alone. The difference between them comes after the winning result: without cancellation, the primary runs for another 120 ms. With immediate cancellation, the total active work is actually less than waiting for the primary alone, even though both attempts needed capacity between 100 and 180 ms. A work-ms is one millisecond of one attempt’s active time, not a measure of CPU usage or cost.

Use Reset to return to the initial times and assumptions. Then change Spare capacity evidence to saturated. The result is STOP for the second launch, not for the primary: the primary still returns at 300 ms. The secondary’s selected duration of 80 ms no longer contributes any work.

Starting a second attempt is not the same as winning

Suppose instead that the primary returns a valid result at 150 ms. With a 100 ms delay, the secondary has already run for 50 ms when the primary wins. Even with immediate cancellation, the caller gains no time and the backend supplies 200 work-ms instead of 150. If the primary returns a valid result at or before the launch delay, the simulation skips the second attempt altogether.

A failure is a completion, but it is not a valid result. If the primary fails at 60 ms, this policy does not wait out the 100 ms delay: provided duplication is safe and capacity is available, the secondary starts at 60 ms and can return at 140 ms. If both attempts fail, there is no time to a valid result. That differs from missing scenario evidence, where the simulation cannot say what happened at all.

Two equal completion times need an explicit tie rule. With primary duration 180 ms, hedge delay 100 ms and secondary duration 80 ms, both valid results arrive at 180 ms; the fixture labels the primary the winner and counts 260 attempt-ms. A primary that completes successfully exactly at the launch delay starts no hedge at all. These are scheduling conventions for this bounded example, not guaranteed network event order.

In practice

First ask what would happen if both attempts performed the operation. If repeating a charge could charge a customer twice, taking just one response does not make the operation safe. Do not hedge when duplicate effects are unsafe or unresolved. Spare capacity cannot settle that question, just as safe repetition does not establish spare capacity.

For an operation known to be safe to repeat, compare the first valid response time with the start and finish times of all attempts. In particular, distinguish a cancellation request from evidence that the losing attempt stopped. Otherwise, work done after the response can disappear from the comparison even though the backend still had to do it.

This simulation uses fixed durations for at most two attempts. Setting capacity to saturated prevents a launch; it does not calculate how a loaded backend slows down. Use the tradeoff, not the example’s 100 ms delay, to guide a decision: judge the potential time saved against the extra work your service can afford, without relying on cancellation to make repeated effects safe.

Frequently asked questions

Editorial questions based on the listed sources and explicitly labeled local examples.

Can a hedge worsen system load?

Yes. A second attempt can consume work even if its response is not used. Apply an explicit budget and evaluate cancellation behavior, particularly during overload.

Should every request be hedged?

No. Hedging sends extra work before the first attempt finishes. Only consider it for operations safe to duplicate, within a resource and deadline budget. Cancellation is not proof that the losing attempt had no effect; the model counts started work under its stated assumptions.

Does cancellation erase consumed work?

No. The toy counts elapsed service work before the modeled cancellation. In a real system, requesting cancellation is not proof that the losing attempt had no effect or that already committed effects were undone. Treat uncertain effects according to the actual operation contract.

Is hedge launch always needed?

No. The fixture suppresses a hedge when a valid primary result arrives at or before the delay. If two launched valid attempts finish together, its tie rule labels the primary the winner; both attempts may still consume work.

Sources & model boundaries

Primary references used for this explanation. The interactive example is an educational model, not a live check.

  1. Dean and Barroso: The Tail at Scale

    Hedged requests. Hedged requests can reduce waiting for slow components by starting redundant work. A lower modeled latency need not mean lower total work.

    Checked .

  2. AWS Builders Library: Timeouts, retries and backoff with jitter

    Retries and side effects; backoff and jitter. Timeouts and retries can amplify load and side effects. Backoff and jitter spread attempts; duplicated operations require separate safety conditions.

    Checked .

Report an issue. Include the article URL and ID, not passwords or access keys.