1. Cache Stampede (Thundering Herd)
- Hot key expired → peak DB
- Solution:
- Request coalescing (single-flight)
- Serve stale data while revalidating.
- Warm up the key (buffer 10%)
- Jitters TTL: 300 seconds + 10% → prevent N cache keys expired at the same time.
2. Cache Penetration
- Request for keys that do not exist
- Problem:
- Negative caching: short TTL make key expired faster
- Bloom filter: in a cache-full application, not existing in the cache is an answer, not touching the database
- Input validation: reject invalid input, some random input (Grafana tools hash) should not reach the database.
3. Cache Avalanche
- Problem: Many keys expired at once.
- Solution: jitter TTLs
4. Hot keys
- Read Sharding: key#0, key#1, key#2,…,key#99
- Write hot counter: counter#0, counter#1,…, counter#99
- Detection: top-K tracking dynamically, apply: Count-Min-Sketch algorithm
- Hot keys: memcache, prewarm.
5. Cold Cache After Restart
- Warm the cache before serving traffic.
- Gradual traffic ramp: 5%, 10%, 15%, 20%,…
- Persistence or replication: on the cache tier
- Never flush a production cache during peak traffic: crash server.
- Verify the database can survive a full cache loss.