Mock Interviewer
Ask Coach
Tap a question to start, or type your own below.
Distributed Cache System Design
Visual Problem Diagram

Scenario
Picture a shop's website during a flash sale. One discounted product ends up in almost every shopper's cart, so every page asks the shop's database for the same product details, thousands of times a second. The shop would rather keep ready-made copies of those popular answers in memory on a group of machines, so most pages never wake the database. That group is called a distributed cache. It only works if the copies stay useful: when every read for that one product lands on a single cache machine, or when a missing copy sends one more identical question on to the database, the cache machines can still look calm while the database melts.
Clarify this problem here, or open Pathway Coach if you want a prep plan first.
This problem asks you to design a distributed cache, which is a group of machines that keep fast, in-memory copies of data so an application does not have to ask its database every time. Think of a shop's website. A product page needs the product's name, price, and stock, and the database is the official place where those facts are kept. Reading from memory is far faster than asking the database, and a database can only answer so many questions every second, so the shop keeps copies of popular products on cache machines and looks there first. Having copies creates three new problems: a copy can be missing, a copy can be out of date after the database changes, and one machine can end up with far more of the traffic than the rest.
In the interview you need to explain five things. First, how one product picks a machine without every product moving when a machine is added. Second, how one very popular product is served by more than one machine. Third, how a database change removes or replaces the cached copy. Fourth, what happens when many requests miss the same value at the same moment. Fifth, what happens when a cache machine dies. Designing the database itself can stay thin.
Constraints
A caller can read, save, or delete one stored value. A value can expire. A full cache can drop values that have not been used. A counter can go up in one step. The cache can save an optional snapshot of memory.
About 99 out of 100 hot reads finish in under 1 millisecond. The cluster stays up about 99.9% of the time. During a network split it still answers, and some answers may be slightly old. You can add machines to grow.
About 10 million operations a second across the cluster, and that read rate is the heavy path. More than 100 gigabytes in one cluster. About 100 million stored values. A few of them get far more traffic than the rest.
Stages ahead
Not ready to design yet?
Try the free Coach trial — ask how to prep, what to practice first, or how InterviewCrafted works. Sign in when you want to start this problem.
Log in to start practicing
Preview the problem below. Sign in to start your timed session, save progress, and use the AI coach.
Want full access now? View Pro pricing