The Cache That Evaporated When a Server Died
#production-outage — cache miss avalanche
PagerDuty: redis-3 died → modulo sharding hash(key) % N remapped ~80% of keys (5→4 shards). Cache hit 95%→12%. DB at 100% CPU.
The trap: Modulo sharding wipes the cache on every topology change.
Your task
Implement `ConsistentHashing` ring methods in `consistent_hashing.py`: virtual nodes, _rebuild_ring(), bisect lookup.
Book: hash % N · Prod: consistent hashing ring — only dead shard keys move.
Skills you'll prove
Interview Tip
When asked about caching or sharding, say: "Modulo sharding looks simple but when a shard dies, changing N remaps almost every key — we had a production outage where cache hit rate dropped from 95% to 12% because hash(key) % 5 became hash(key) % 4. The fix was consistent hashing: shards on a ring, keys map to the nearest node clockwise, 150 virtual nodes per shard for balance. When one Redis died, only that shard's keys moved. The rest of the cache stayed warm."