A thundering herd (also called a retry storm) is a load spike that occurs when a large number of clients, processes or retries act at the same moment on the same resource, for example after an outage, a cache expiry or a scheduled job. The synchronized burst can overload the resource again and keep a system from recovering.
What is a thundering herd?
The thundering herd problem describes a crowd that starts moving at the same moment. Originally the term comes from operating systems: many processes sleep while waiting for the same event, the event occurs, all of them are woken up, but only one can actually handle it. The rest wake up for nothing and waste CPU. Linux addressed a classic case with the EPOLLEXCLUSIVE flag for epoll, introduced in kernel 4.5.
In distributed systems the term is used more broadly for any synchronized burst of requests. A retry storm is the most common variant: a service is slow or briefly unavailable, all clients retry, and the retries add up to more load than the original traffic.
Common causes
- Recovery after an outage: when a database or service comes back, every waiting client reconnects and resends at once. Reconnecting connection pools are a typical source.
- Cache stampede: a popular cache key expires and hundreds of requests miss the cache at the same time and all query the database to rebuild the same value.
- Synchronized schedules: cron jobs, batch exports or client polling that all run at the full hour.
- Fixed retry intervals: clients that retry every second on the second stay in lockstep forever.
- Mass restarts: a deployment or a node failure restarts many instances that warm caches and load configuration simultaneously.
Why retries amplify load
Retries multiply across layers. If a front end, an API gateway and a back-end service each retry three times, a single user request can turn into dozens of calls to the failing dependency. At exactly the moment the dependency is weakest, it receives the most traffic. That is why a short incident can turn into a long one: the system cannot get back on its feet while it is being hammered.
How to prevent a thundering herd
- Exponential backoff with jitter: wait longer after each failed attempt and randomize the delay, so clients spread out instead of retrying in lockstep.
- Retry budgets: allow retries only up to a small percentage of normal traffic, and retry only at one layer of the stack.
- Circuit breakers: stop calling a failing dependency for a while and probe it carefully before sending full traffic again.
- Request coalescing: let only one request rebuild an expired cache entry while the others wait for its result, for example with Go's
singleflightpackage or a lock per key. - Staggered expiry and schedules: add random offsets to cache TTLs and cron times.
- Load shedding and admission control: reject excess requests early with a clear status code and a
Retry-Afterheader, which is a form of backpressure. - Gradual warm-up: bring traffic back to a recovered service step by step.
How to detect it
A thundering herd has a recognizable shape in telemetry: request rate to a dependency jumps far above normal traffic right after an error spike or a recovery, often in regular waves that match a fixed retry interval. Useful signals are the ratio of retries to original requests, connection attempts per second against a database, cache miss rate on hot keys and the alignment of spikes with deployments or the start of the hour. In traces, a single user request with many sibling spans calling the same failing endpoint is a strong hint.
After the incident, look at the recovery phase as carefully as at the original failure. A postmortem should answer how much of the downtime was caused by the initial fault and how much by the herd that followed. Typical findings are retry settings copied from library defaults, timeouts that were longer than the retry interval and caches that were all filled at the same time after a deploy. Turning these findings into configuration standards, for example a shared retry policy with backoff and jitter for every HTTP client, prevents the same pattern in other services. Load tests that simulate a dependency going down and coming back are the best way to verify the fix.
How Obseria helps
With distributed tracing, Obseria shows retries as separate spans, so amplification across layers becomes visible per request. Anomaly detection flags sudden jumps in request or connection rates, and Obseria Intelligence relates them to the outage, deployment or cache expiry that triggered the herd.