Skip to the guide

Distributed caches at scale

AdvancedConcept3 pages

One Redis node and a replica cover a lot. Past terabytes of hot data and a million reads a second, the cache becomes a fleet, and the database behind it is sized on the assumption that the fleet works. Interviewers probe what happens when part of it doesn't.

The hotel linen cupboards

A large hotel keeps a linen cupboard on every floor, so housekeepers don't walk to the basement laundry for each room. Each cupboard serves a fixed set of rooms. If one is locked, all its housekeepers go down to the laundry at once, and the laundry, staffed for the odd top-up, falls behind. So the hotel either keeps a spare cupboard ready to take over, or stocks two cupboards for every set of rooms. When a new wing opens, its empty cupboards are filled from the old wing's cupboards, not from the laundry.

  • cupboards → cache nodes, each owning a share of the keys (the rooms)
  • housekeepers → the app servers that read them
  • the laundry → the database, sized for the misses only
  • a locked cupboard → a failed node
  • the spare cupboard → a gutter pool; two stocked cupboards → replicas
  • filling the new wing from the old → warming a cold cluster