Layer 3 · Go deeper · 11 min
Go deeper
Size it, build it, then make the calls an interviewer will push you on.
Back of the envelope
Size it up
Tap through each step of the arithmetic.
How many cache nodes, and what sets the number?
Does the network limit a cache node?
How many connections does each cache node hold?
Build-up · 5 steps
Build the high-level design
One functional requirement at a time, ending with a cache that works in one region at moderate load.
Step 1 of 5
Get, set and delete by key
30 TB won’t fit on one machine. A library in each app pod hashes the key to one of 16,384 slots, finds the owner in a pushed slot map, and calls that node directly.
6 interview moments
You’re the candidate
The interviewer pushes on the hard parts. Pick an approach and see how it holds up.
Deep dive 1 of 6
Interviewer
“You run 250 cache primaries and must add capacity before the sale. How does every router agree which node owns a key?”
Your move. Pick an approach:
Deep dive 2 of 6
Interviewer
“Prices change in the database while thousands of readers hit each cached product. How do you keep the cache in step?”
Your move. Pick an approach:
Deep dive 3 of 6
Interviewer
“The ₹9,999 phone is read 50,000 times a second when its entry expires. The query takes 50 ms under sale load. What do you do?”
Your move. Pick an approach:
Deep dive 4 of 6
Interviewer
“World Cup final, last over: the 2 KB score key gets 1M reads a second on a node budgeted for 200k. Now what?”
Your move. Pick an approach:
Deep dive 5 of 6
Interviewer
“A pool’s memory is full and fills keep arriving at sale load. What should each node do?”
Your move. Pick an approach:
Deep dive 6 of 6
Interviewer
“With 300 nodes, one is always failing. A primary serving 36k reads a second just died. Where does its traffic go?”
Your move. Pick an approach:
Build-up · 7 steps
Follow a read and a price change
The hot path is the app, its host’s sidecar and one cache node. Everything else is the miss path, a background pipeline, or there for when something breaks.
Step 1 of 7
Near cache
The app asks its host’s sidecar for catalog:v7:product:12345. A hot-list key is answered from the one-second near cache and never leaves the host.