Layer 3 · Go deeper · 6 min
Go deeper
Size it, build it, then make the calls an interviewer will push you on.
Build-up · 5 steps
Turn up the writes on one row
One row, a 20 ms window. Raise the conflicting writes a second and watch what each strategy pays.
Step 1 of 5
One write a second
λt = 0.02. An optimistic attempt meets a conflict 2% of the time; a lock is busy 2% of the time. Both are cheap.
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
“Ten workers pull from one jobs table. How does each claim jobs without two workers grabbing the same one?”
Your move. Pick an approach:
Deep dive 2 of 4
Interviewer
“A slow transaction holds a row that checkout’s
FOR UPDATEneeds. Checkouts hang and the connection pool drains. What do you change?”Your move. Pick an approach:
Deep dive 3 of 4
Interviewer
“Checkout reads and updates a row, and calls a payment gateway that takes 400 ms in between. How do you structure it?”
Your move. Pick an approach:
Deep dive 4 of 4
Interviewer
“Your optimistic writes now conflict 30% of the time. What do you do first?”
That’s λt ≈ 0.36, about 1.43 attempts per success.
Your move. Pick an approach:
Build-up · 5 steps
Watch two transfers lock each other out
Asha pays Bilal ₹500 while Bilal pays Asha ₹300. Each transfer debits its payer first, so each locks a different row first.
Step 1 of 5
Two wallets, two transfers
Row 101 is Asha’s wallet and row 205 is Bilal’s. T1 moves ₹500 from Asha to Bilal while T2 moves ₹300 the other way.