Are a thundering herd and a retry storm the same failure?
- Posted
- Tags
- reliability, sre, distributed-systems
Two failure modes that look alike under load, but start differently and need different fixes.
I was stuck in traffic today, annoyingly so, and started wondering whether failed or slow data requests feel the same when a system's performance degrades. That led me to two failure modes I only run into once in a while at work: the thundering herd and the retry storm. "Aren't those the same thing?", I asked. Not quite. Not completely.
The question I had
Are a thundering herd and a retry storm the same failure?
What I found
They are different failure modes, and one can trigger the other.
| Thundering herd | Retry storm | |
|---|---|---|
| Typical trigger | An expired cache | A degraded service, slow or unable to process requests |
| What happens | Many requests hit the service or database at the same moment | Each failed request is retried, multiplying the request flow |
| Why it hurts | A sudden influx overwhelms the service | The extra load keeps the service from recovering on its own |
So a thundering herd is a sudden influx of requests. A retry storm is a struggling system getting pushed further down by the retries it caused. A herd can overload a service enough to start a storm.
Service-level fixes
For the thundering herd:
- Request coalescing. Combine many identical requests into one that hits the service or database and fills the cache, instead of letting them all through.
- Staggered or jittered cache expiry. Add a bit of randomness to expiry times so cache items do not all expire at once.
For the retry storm:
- Exponential backoff with jitter. Retry after increasing waits (1, 2, 4 seconds) to give the service room to breathe, and add randomness so every client does not retry at the same moment.
- Circuit breakers. A switch that cuts the request flow to a struggling service and returns a cached or graceful fallback, so the service can recover. It can live in a client library, a service mesh or the API gateway.
- Rate limiting and throttling. A hard cap on how many requests a user can send per second, so one client cannot abuse the server.
For both, the app decides what matters most:
- Adaptive throttling or shedding. Deliberately drop telemetry and other unimportant requests to protect the high-priority ones.
- Graceful degradation toggles. A set of kill switches (feature-level circuit breakers) to turn off expensive workloads.
Infrastructure fixes
- Load balancer queueing and dropping. Manage requests at the load balancer and let only a healthy number reach the application.
- Predictive or proactive auto-scaling. Scale up on a schedule when traffic is expected, or whenever CPU and memory run high.
- Decoupling with message queues. Put Kafka, SQS or RabbitMQ in between so requests pile up in the queue and services pick them up at their own pace. A dead letter queue collects requests that keep failing, for SREs to investigate.
Practice
- Chaos engineering game days. Put staging into a simulated degraded state to find failure modes and test the mitigations, like auto-scaling and circuit breakers.
Takeaway
A thundering herd and a retry storm are two common failure modes that can come from one another, but they are not the same. One is a sudden influx of requests. The other is a degraded system made worse by its own retries. Service-level logic and infrastructure capacity planning each help address both.
Sitting in that traffic, it clicked: SREs are the traffic lights, keeping requests moving, and the road designers, building a system that can handle the rush.