109
cache stampede
also thundering herd
The hot key expires and every request rebuilds it at once. One recomputation. The rest wait or get stale.
What is cache stampede?
A stampede is a rush of identical work when a cache entry disappears. A thundering herd is the same pile-on against a database, a lock, or a cold service. One expensive query becomes a thousand.
Why does cache stampede matter when vibe coding?
Models cache with a TTL and no lock. At expiry the database sees the whole fleet. Say single-flight or early refresh.
How do you do cache stampede?
One worker rebuilds the key. Others wait or serve slightly stale. Refresh before expiry for hot keys. Jitter the TTL so keys do not die together.
How do you ask a model for cache stampede?
Prevent a stampede on (key). Only one request recomputes it. Others wait or serve stale. Jitter TTLs. Do not let every instance miss and query at once.
What goes wrong with cache stampede?
A lock that never unlocks when the rebuilder dies. The key stays missing. Put a deadline on the lock.