Thundering herd problem

On this page 7

The thundering herd problem is a failure pattern in which a large number of waiting processes, workers or clients are released at the same moment and compete for a single shared resource, so the burst of simultaneous demand overwhelms that resource or wastes most of the work performed. In automation and reliability engineering, it appears whenever scheduled jobs, workflow workers or API clients act on the same trigger at the same instant, such as a cache expiry, a lock release, a service restart or a cron boundary.

The pattern matters because it turns a recovering or briefly idle system into an overloaded one. A dependency that could easily serve steady, spread-out traffic fails under a synchronized spike, which often triggers further retries and prolongs the outage.

How a thundering herd forms

A thundering herd forms when many consumers share one wake-up signal and nothing staggers their response. The classic operating system case involves several processes blocked on the same socket: when one connection arrives, the kernel wakes all of them, yet only one can accept it, and the rest return to sleep after consuming CPU and context switches for nothing.

Distributed automation reproduces the same shape at a larger scale. Each participant behaves correctly in isolation, but identical timing logic across hundreds of instances produces correlated behavior. The herd is therefore an emergent property of the system, not a defect in any single component, which is why it frequently escapes unit tests and only appears under production load.

The table below lists the most common triggers in automated systems and the resource each one tends to overload.

TriggerWhat happensResource under pressure
Cache expiryMany requests miss the same key and recompute itDatabase or origin service
Lock releaseAll waiters wake and contend for one lockCPU, lock manager
Service recoveryQueued clients reconnect the moment health checks passRecovering service
Scheduled jobsCron tasks across a fleet fire at the top of the hourShared API or warehouse
Fixed retry delaysFailed calls retry in lockstep after identical waitsDownstream dependency
Typical triggers of a thundering herd

Why synchronized demand causes outages

Synchronized demand causes outages because capacity is sized for average load, not for the entire population acting in the same second. A service that handles 2,000 requests per second comfortably may collapse when 20,000 clients reconnect within one second, even though its daily total traffic is unchanged.

The damage compounds through feedback loops. Overloaded requests time out, clients retry, and those retries arrive together again, which is how a herd escalates into a retry storm. Latency also rises sharply as queues fill, so even requests that succeed may exceed caller timeouts and be counted as failures. Recovery can stall indefinitely when every restart attempt meets the same wall of synchronized traffic.

  • Wasted work: many workers compute the same result, and all but one discard it.
  • Resource exhaustion: connection pools, file descriptors and thread pools fill at once.
  • Cascading failure: an overloaded dependency slows its own callers, spreading the incident.
  • Metastable failure: the system stays degraded even after the original trigger disappears.

The thundering herd problem overlaps with several neighboring concepts in reliability, but each describes a different cause or a different remedy. Distinguishing them helps teams choose the right fix instead of applying a generic retry rule.

ConceptCore ideaRelation to the herd
Retry stormRetries multiply load on a failing serviceOften the consequence of a herd
Cache stampedeConcurrent recomputation of one expired keyA specific herd variant
Exponential backoffIncreasing waits between attemptsReduces rate but not synchronization
Retry jitterRandom variation added to wait timesBreaks synchronization directly
Retry budgetCaps retries as a share of trafficLimits how large a herd can grow
Related concepts and how they differ

A frequent misconception holds that exponential backoff alone prevents a herd. It does not: if every client starts at the same moment with the same base delay, they still retry together at 1, 2, 4 and 8 seconds. Jitter is the component that desynchronizes them.

Mitigation techniques for automated workflows

Mitigation works by spreading demand over time or by ensuring only one participant does the expensive work. Most production designs combine several techniques, because each addresses a different trigger.

TechniqueMechanismBest suited to
Full jitterRandom delay between zero and the backoff ceilingClient retries after failures
Request coalescingOne request fetches, others wait for its resultCache misses on hot keys
Early probabilistic refreshEntries refresh randomly before expiryHigh-traffic cached values
Staggered schedulesOffsets cron times per instanceFleet-wide scheduled jobs
Admission controlRate limits or token buckets at the entry pointRecovering services
Single-waiter wakeupWakes one waiter instead of allLocks and socket accept loops
Mitigation techniques and when to apply them

In workflow orchestration, staggering is usually the cheapest fix. Scheduling a job at a random minute within a window, rather than at 00:00, removes the spike without changing the job itself. For reconnecting clients, a gradual ramp-up of admitted traffic lets a service warm caches and connection pools before full load returns.

Common mistakes and warning signs

Teams usually discover a thundering herd through sharp, periodic load spikes that line up with clock boundaries, deployments or cache lifetimes. The table below links typical symptoms to their likely cause and a corrective action.

SymptomLikely causeFix
Spikes at the top of each hourIdentical cron expressionsRandomize start offsets
Database load jumps when a key expiresUniform cache TTLAdd TTL jitter or coalescing
Service fails again right after restartAll clients reconnect togetherRamp admission gradually
Retries cluster at fixed intervalsBackoff without jitterApply full or decorrelated jitter
Symptoms, causes and fixes

A further mistake is testing resilience with a handful of instances. Synchronization effects scale with population size, so load tests should reproduce realistic client counts and shared triggers to reveal the problem before production does.

The short version

Imagine a shop that opens its doors at exactly 9:00 in the morning while hundreds of people wait outside. Everyone rushes in at once, the aisles jam and the cashiers cannot cope, even though the shop could serve the same crowd easily over an hour.

The thundering herd problem is that same rush inside computer systems. Many programs wait for the same signal and all react together. The cure is simple in principle: make them arrive at slightly different times, or let one go first and share the result with the others.

Where it makes a difference

A logistics company runs 800 automation workers that each refresh a pricing table from an internal API every hour. All workers use the same schedule, so at the start of every hour the API receives 800 requests within a few seconds. Response times climb from 80 milliseconds to more than 6 seconds, workers time out and retry together, and the API restarts twice a day.

The platform team makes two changes. Each worker now starts at a random offset within a 10-minute window, and failed calls use exponential backoff with full jitter. The hourly peak falls to roughly a tenth of its former height, the API stops restarting, and the pricing data still refreshes well within its one-hour freshness target. No additional capacity was required, only a change in timing.