Module 04
Caching
- Cache-aside / write-through / write-back / write-around
Send the same write and read sequence through each strategy and compare latency, stale windows, and data lost when the cache crashes.
- TTLs, invalidation & stale reads
Update a product price and compare TTL expiry with explicit invalidation, including the race where a slow reader repopulates the cache with the old value.
- Cache stampede / thundering herd
Let a hot key expire under load and watch the database get flooded, then layer on coalescing, jittered TTLs, stale-while-revalidate, and prewarming.
- Hot keys
One celebrity key saturates a single cache shard, fixed by key replication or a local L1 cache.
- Negative caching
Requests for nonexistent IDs bypass the cache and hammer the database until "not found" results are cached too.
- Cache outage
Take the cache offline and see whether falling back to the database overloads it, and what a circuit breaker does.