Layer 3 · Go deeper · 7 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 double charges does a fresh key per retry cause?
Can two clients’ random UUID keys collide?
Build-up · 6 steps
Survive a crash mid-charge
A checkout that charges a card can’t be one database transaction. Split it into atomic phases with recovery points, and a retry resumes where the last attempt stopped.
Step 1 of 6
Claim the key
tx1 inserts key K as in progress and commits the recovery point started. Each box is one local database transaction.
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
“A fitness app syncs each day’s step count, and sync retries are common. How do you write it?”
Your move. Pick an approach:
Deep dive 2 of 4
Interviewer
“POST /orders assigns a fresh ID every time, so retries create duplicate orders. What’s the cheapest fix?”
Your move. Pick an approach:
Deep dive 3 of 4
Interviewer
“To stop duplicate payments, a teammate suggests rejecting any request whose body hash was seen recently. Do it?”
Your move. Pick an approach:
Deep dive 4 of 4
Interviewer
“Payments live in PostgreSQL. The team wants the idempotency keys in Redis for speed. Your call?”
Your move. Pick an approach: