Caching in anger
Write-through to consistent hashing: the failure modes that only show up under load, and why most cache incidents are design decisions coming home.
Read in order: later instalments assume the earlier ones.
- 01 Write-through, write-behind, write-around: picking wrong costs you consistency or throughput
What each write strategy actually guarantees when the process dies mid-operation, why write-behind is the only one that can lose acknowledged data, and why write-around is the right default more often than people expect.
- 02 Cache stampede: how one expired key takes down the database
Why TTL expiry is a synchronised event that sends every concurrent request to the origin at once, why the pileup amplifies itself while the recompute runs, and why jitter is the cheapest fix nobody applies.
- 03 Jitter is the cheapest reliability fix you are not using
Why independent clients converge on the same instant without any coordination, how retries, cron schedules, health checks and reconnects all self-synchronise, and why adding randomness is a one line fix for a class of outage.
- 04 Negative caching: the misses cost more than the hits
Why a cache that only stores successes leaves the expensive path completely unprotected, how an attacker turns that into a denial of service with random keys, and why caching absence needs a different TTL than caching presence.
- 05 Cache invalidation is a distributed systems problem in a convenience costume
Why deleting a key after a write is a two phase commit you did not design, how the update-then-invalidate ordering produces permanent staleness, and why invalidating rather than updating is the one decision that reliably helps.
- 06 Local cache plus distributed cache: the coherence bill nobody budgets for
Why adding an in-process cache in front of Redis turns one consistency problem into N, why a pub/sub invalidation that nobody retries is a guarantee you do not have, and why the local TTL is the real bound on how wrong you can be.
- 07 Why your Redis is slow: it is single threaded and you sent it KEYS
Why one O(N) command blocks every other client on the server, which everyday commands are secretly linear, and why a p99 spike with flat CPU is almost always somebody scanning the keyspace.
- 08 Scaling a distributed cache: Why consistent hashing is mandatory
Why modulo-based cache sharding fails in production and how consistent hashing with virtual nodes protects your database.
- 09 Hot keys defeat consistent hashing
Why a perfectly balanced ring still sends one celebrity key to one node, why adding cache nodes makes no difference to that node, and the three ways to split a key that a hash function cannot split for you.