Interactive Systems Explainers

Cache Stampede Playground

See one cache expiry overload a database.

i
Cache stampede experiment controls

Key Observations

What to Notice

What a cache stampede is

A warm cache keeps most requests fast. When it expires, many clients can ask for the same missing value together.

Why expiration creates spikes

The requests were harmless hits a moment ago. After one shared expiry, they turn into one synchronized miss wave.

Why the database gets overloaded

Every miss tries to rebuild through the database. If rebuilds arrive faster than the database can finish, the queue blooms.

How coalescing helps

Protection lets one request rebuild while the rest wait briefly or use stale cache, keeping the database calm.

Real-World Context

Cache stampedes show up when many users or services depend on the same cached value: home page data, feature flags, product catalogs, pricing, permissions, or expensive aggregate queries.

The awkward part is that the cache can turn from protection into synchronization. Common mitigations include jittered expiration, stale-while-revalidate, request coalescing, and prewarming. Each reduces spike risk while accepting tradeoffs in freshness, complexity, or temporary staleness. The failure can be sharp because expiry aligns otherwise independent callers into one wave.

Interactive Systems Explainers

Explore Next