Skip to content

Cache stampede

A cache stampede occurs when concurrent cache misses trigger the same expensive calculation or data query repeatedly.

Software architecture

A cache stampede occurs when many requests need the same unavailable cache entry at roughly the same time and trigger the same work at the data source. An expired entry or a cache starting empty can therefore cause a load spike.

In a fictional dashboard, 100 concurrent requests within the same authorised data scope look up summary:tenant-7. If the summary is absent and nothing coordinates the work, many identical recalculations may start.

Coalesce requests for the same data

Request coalescing groups these lookups: an ongoing recalculation is shared for the same key and data scope. Other requests wait for the result in a controlled way or receive an older value if the business freshness rule permits it. Coalescing must not combine different user or authorisation scopes.

A lock effective only within one process does not automatically coordinate all servers. Failed calculations and requests waiting too long also need a bounded failure path. Cache invalidation decides when an entry is no longer usable; stampede protection manages concurrent renewal.

Sources