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 requests can a token bucket admit in t seconds?
What happens when the database slows from 50 ms to 500 ms?
How do retries multiply through five layers?
Build-up · 5 steps
A token bucket meets a burst
Set to r = 5 a second with a burst of b = 5, fed the same trace: 14 requests in 0.7 s, then a steady 4 a second.
Step 1 of 5
A full bucket
The bucket holds up to b = 5 tokens and refills at r = 5 a second, one every 200 ms. Store only the count and the last update time.
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 public API must absorb the dozen calls an app screen fires at once, yet hold 50 a second long-run. Which algorithm?”
Your move. Pick an approach:
Deep dive 2 of 4
Interviewer
“Limit OTP sends to 5 per phone number per 15 minutes. Which algorithm fits?”
Your move. Pick an approach:
Deep dive 3 of 4
Interviewer
“The gateway runs 50 pods behind a round-robin balancer. Where do the per-key counters live?”
Your move. Pick an approach:
Deep dive 4 of 4
Interviewer
“The Redis behind your limiter goes down at peak. What should the limits do?”
Your move. Pick an approach: