Hedged Requests for Reducing Tail Latency in Distributed Systems
Distributed Systems
System Design
Performance Engineering
Software Engineering
How delayed duplicate requests reduce tail latency and what they mean for backend load, cancellation, and idempotency.
In distributed systems, average latency can hide the delays users experience. Tail latency often determines how slow the system feels.
Hedged requests work in three steps.
- Send a request to one replica.
- If it hasn’t returned after a preset delay, send the same request to another replica.
- Use whichever response arrives first, then cancel the remaining request or ignore its response.
Response times across replicas are often imperfectly correlated. A second replica can respond quickly while the first is still working. Sending a duplicate request raises the chance of getting a quick response.
Hedging comes with tradeoffs.
- Extra requests increase network traffic and backend load.
- Limit the fraction of requests that are hedged.
- Account for how outstanding requests can be canceled.
- Use particular care with non-idempotent operations.
- Network congestion and failures that affect multiple replicas can undermine hedging. Extra requests can even make the problem worse.
A small amount of redundancy can reduce the chance that a user has to wait for an exceptionally slow response.