Layer 3 · Go deeper · 12 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 much click data arrives, and how much do you keep?
How much state to remember an hour of click IDs?
How many aggregate rows a day, at minute, hour and day grain?
How big must the stream job be to survive an outage?
Build-up · 5 steps
Build the high-level design
One requirement at a time: redirect, fresh metrics, billing, pacing. It works, until it meets crashes, late clicks, a hot ad and bots.
Step 1 of 5
Redirect and record the click
The click server checks the signed token, derives the click ID from the impression ID and appends to a local spool before the 302. Kafka is off the user’s path, so a broker incident never blocks a redirect.
6 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 6
Interviewer
“A Flink restart replays everything since the last checkpoint. How do you make every click affect the count exactly once?”
Your move. Pick an approach:
Deep dive 2 of 6
Interviewer
“After a 10-minute outage, the job reads a 600M-click backlog in a rush. Which minute does each click count in?”
Your move. Pick an approach:
Deep dive 3 of 6
Interviewer
“During an IPL final’s toss, one sponsor’s ad draws 400,000 clicks a second, 40% of traffic. How do you keep the job moving?”
Your move. Pick an approach:
Deep dive 4 of 6
Interviewer
“Bots, click farms and slipped thumbs are mixed in with real clicks. How do you keep them out of the counts and the bill?”
Your move. Pick an approach:
Deep dive 5 of 6
Interviewer
“An advertiser disputes March in July, and a bug overcounted for six hours. Where should billing numbers come from?”
Your move. Pick an approach:
Deep dive 6 of 6
Interviewer
“6,000 dashboard queries a second, some over 30 days, must answer in under a second. What do you store and read?”
Your move. Pick an approach:
Build-up · 8 steps
Follow one click through it
The user waits only for the click server and its spool. Everything else is asynchronous, and everything that touches money is idempotent by construction.
Step 1 of 8
Click
The click server verifies the token, stamps the event time with its own clock, never the phone’s, derives the click ID, group-commits to its spool and returns 302. A few milliseconds, no remote call.