Chapter 2: The 3 Caching Vulnerabilities (Penetration, Breakdown, Avalanche) & Go Singleflight
Multi-Language Edition: This chapter is also available in Vietnamese at 📖 Bản tiếng Việt (Vietnamese Edition). Previous: Chapter 1 — High Concurrency System Design in Go | Series Hub | Next: Chapter 3 — Distributed Rate Limiting with Redis & GCRA Answer-First: Caching at C10M scale requires a multi-layered defense against three fatal production failure modes: (1) Cache Penetration (non-existent keys bypassing cache) is eliminated using in-memory Scalable Bloom/Cuckoo Filters and null-object caching; (2) Cache Avalanche (simultaneous expiration of millions of keys) is prevented by adding randomized TTL Jitter (e.g., (\text{base} \pm 15%)) and asynchronous background re-warming; and (3) Cache Breakdown / Stampede (a single hot key expiring under massive concurrency) is completely solved using Go’s `golang.org/x/sync/singleflight` to coalesce thousands of concurrent requests into a single database query. ...