Hedging & Fallback Strategies for Tail Latency Reduction
1Concept
Hedging dispatches duplicate concurrent requests if the primary request takes longer than expected (e.g. p99 > 200ms), taking the result from whichever completes first to eliminate tail latency spikes.
2Architecture Diagram
Primary Request Dispatched
│ (Takes > 150ms)
├──> Hedged Duplicate Request Dispatched to Replica Server 2
│
Whichever finishes first wins; the slower request is cancelled!3Code Example
C# 13 & .NET 9
using System;
public class HedgingConceptDemo
{
public static void Main()
{
Console.WriteLine("Polly Hedging Strategy reduces p99 tail latency in financial & search APIs.");
}
}4Expected Output
Polly Hedging Strategy reduces p99 tail latency in financial & search APIs.
5Key Takeaways
- ✓Hedging dramatically reduces p99 and p99.9 latency spikes.
- ✓Only use hedging for idempotent read operations (e.g. GET/search).
- ✓Configure timeout thresholds carefully to prevent server load spikes.