A popular cache key expires and thousands of requests hit the DB at once. This is…
Options
- Cache stampede (thundering herd) (Correct option)
- Split brain between two nodes
- Hot partition on one shard
- Replication lag on a read replica
Answer
Cache stampede (thundering herd)
Why
While the key was cached, the database was protected. The moment it expires, every request misses at the same time and all of them query the database to rebuild the same value, which can overload it.
Fixes: let only one request rebuild it (a lock) while others wait or get the old value; refresh shortly before expiry; add random jitter to TTLs so keys don't all expire together.
Remember
Many misses at once on a hot key = cache stampede.