Cachingreconnect stormthundering herd problem

Thundering herd

Definition

A thundering herd is a load spike caused by a large number of waiters reacting to the same event simultaneously, such as a cache entry expiring, a service coming back up or a scheduled time arriving.

In practice

Typical triggers are synchronised retries after an outage, thousands of WebSocket clients reconnecting when a server restarts, cron jobs all set to midnight, and a hot cache key expiring (a cache stampede). The spike can knock the recovering service straight back down, which turns a short outage into a long one.

The cure is to desynchronise and limit: jitter on retries, reconnects, TTLs and schedules; exponential backoff; request coalescing for cache misses; and admission control or load shedding on the server. Simply adding capacity rarely works, because the herd is sized by the number of clients, not by normal traffic.

Example

A chat server restarts and 200,000 clients reconnect within 2 seconds; with reconnect delays jittered over 0 to 30 seconds, the peak drops to about 7,000 connections per second.