Strategies
Read-through: cache fills on miss. Write-through: writes go to cache and origin synchronously. Write-back: writes go to cache first, flushed to origin async — fastest, but risks data loss on crash.
TL;DR
Caches collapse latency and protect origins. They also cause cache stampedes, stale reads, and hot-key outages. In an interview, name the strategy (read-through / write-through / write-back), the invalidation mechanism (TTL / event-driven), and the failure mode (stampede, hot key) out loud.
Read-through: cache fills on miss. Write-through: writes go to cache and origin synchronously. Write-back: writes go to cache first, flushed to origin async — fastest, but risks data loss on crash.
TTL is simplest but produces staleness. Event-driven (cache-bust on write) is precise but requires a write pipeline. Versioned keys (key:v7) avoid invalidation entirely.
Cache stampede: N clients race to fill a missing key on expiry. Mitigate with probabilistic early refresh or a singleflight lock. Hot key: one key gets 10× traffic. Mitigate with request coalescing or key sharding.
P95 hit rate is the number to target. A cache that hits 70% is often the right tradeoff; 95% requires huge memory or unfair LRU eviction. Narrate the target hit rate explicitly.
Book a 45-minute system design mock with a transcript. Included in the $19/mo subscription.