Layer 3 · Go deeper · 8 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 queries does one expiry send to the database?
What does TTL jitter do for 2 million keys loaded together?
Build-up · 5 steps
Stop one stampede, fix by fix
One key read 20,000 times a second, a 200 ms recompute and 200 app pods. Each fix cuts the database queries per expiry.
Step 1 of 5
No protection
The key expires and every request in the next 200 ms misses and queries, 20,000 × 0.2 = 4,000. Concurrent queries slow the database, which lets even more requests miss.
4 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 4
Interviewer
“The live-score key takes 400,000 reads a second during an IPL final, and its shard is at 100% CPU. What do you do?”
Your move. Pick an approach:
Deep dive 2 of 4
Interviewer
“A live poll counts 300,000 votes a second on one Redis counter. How do you cool a hot write key?”
Your move. Pick an approach:
Deep dive 3 of 4
Interviewer
“After a bulk catalogue re-import, millions of cached product keys are stale at once. How do you invalidate them?”
Your move. Pick an approach:
Deep dive 4 of 4
Interviewer
“A bot walks never-issued product IDs at 5,000 requests a second. Every request misses the cache. What do you add?”
Your move. Pick an approach: