System Design
The read/write patterns (cache-aside, read/write-through, write-back), eviction policies (LRU/LFU/TTL), and the two hard problems — stale reads and the thundering herd — with the mitigations that actually work.
Updated August 30, 2026 · 5 min read
| Cache-aside (lazy) | App checks cache, loads from DB on miss, then populates.Most common; cache can go stale until TTL. |
|---|---|
| Read-through | Cache library loads from DB on miss transparently. |
| Write-through | Write hits cache and DB synchronously.Consistent, slower writes. |
| Write-back (write-behind) | Write to cache, flush to DB async.Fast writes; risk of loss on crash. |
| Write-around | Write straight to DB, skip cache.Avoids caching write-once data. |
| LRU | Evict least-recently-used.Good default for temporal locality. |
|---|---|
| LFU | Evict least-frequently-used.Better for stable hot sets. |
| TTL | Expire after a fixed time.Simple staleness bound. |
| FIFO / random | Cheap, ignores access pattern. |
| Stale reads | Cache diverges from source.Bound with TTL, or invalidate on write. |
|---|---|
| Thundering herd / stampede | A hot key expires and every request hits the DB at once.Fix: request coalescing, jittered TTLs, probabilistic early refresh. |
| Hot keys | One key gets disproportionate traffic.Fix: local (L1) cache, key replication. |
| Cold start | Empty cache after deploy/restart floods the DB.Fix: warm-up, gradual ramp. |