Layer 3 · Go deeper · 5 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.
Build-up · 5 steps
Keep a hot counter correct and fast
Every order bumps dishes.times_ordered. Watch two orders race, then a one-rupee biryani offer arrive.
Step 1 of 5
Read, add, write loses one
The app reads times_ordered = 1200, adds 1 and writes 1201. Two concurrent orders both write 1201, and one increment is gone. That’s a lost update.
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
“Dish search documents need the restaurant’s name, and restaurants get renamed. How do you keep that copy right?”
Your move. Pick an approach:
Deep dive 2 of 4
Interviewer
“Menus show “ordered 12k times”. Order lines are inserted by the API, an admin tool and bulk imports. How do you maintain times_ordered?”
Your move. Pick an approach:
Deep dive 3 of 4
Interviewer
“A restaurant sales dashboard aggregates millions of order lines on every load. Numbers a few minutes old are fine. What do you build?”
Your move. Pick an approach:
Deep dive 4 of 4
Interviewer
“On DynamoDB, a restaurant’s name is copied into thousands of items, and the restaurant is renamed. How do you update the copies?”
Your move. Pick an approach: