Design a distributed cache
by quasar_realm592
8
42
I started by clarifying the workload: read-heavy, low-latency lookups, and roughly 10 million keys across regions. I proposed a sharded cache with consistent hashing, replication for availability, and an explicit eviction policy; the interviewer agreed the scope was clear, then asked how I would handle hot keys.
I suggested request coalescing, short-lived local caching, and splitting hot keys across replicas. We discussed stale data: I went with TTLs plus versioned invalidation from the source of truth. The interviewer pushed on what happens when invalidation events are lost, and my answer was too hand-wavy until I added periodic reconciliation.
For failures, I covered node replacement, rebalancing, and bounded retries, but I underestimated the load spike when a shard comes back cold. The interviewer called that out; I added warmup from sampled traffic and jittered TTLs, though I didn’t quantify the recovery capacity. We also touched on metrics like hit rate, p99 latency, and eviction rate.
The conversation was technically solid, but I spent too long on hashing details and left little time to compare consistency guarantees. The interviewer was engaged and gave useful nudges, but said the cold-start and failure-mode discussion needed more depth. Outcome: rejected.