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 fast does the input journal grow?
How much market data at peak, and what would TCP cost?
How much memory do all the order books need?
How many single-threaded engines does the design peak need?
Build-up · 6 steps
Build the high-level design
One functional requirement at a time, ending with an exchange that works for one partition of symbols, without failover.
Step 1 of 6
Place and cancel orders
The gateway rejects junk, like a price off the ₹0.05 tick, before it costs the core anything. The sequencer stamps #1042 and journals it before the engine acts: that number is the order’s place in time.
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
“Most traffic is orders being added, cancelled and replaced, at up to 2 million a second. How do you store each book?”
Your move. Pick an approach:
Deep dive 2 of 6
Interviewer
“You have dozens of cores and 5,000 books, and every order changes the book the next one sees. How do you thread the matching?”
Your move. Pick an approach:
Deep dive 3 of 6
Interviewer
“A crash wipes the in-memory books, but members already hold acknowledgements and fills. How do you make sure no trade is lost or changed?”
Your move. Pick an approach:
Deep dive 4 of 6
Interviewer
“Brokers, vendors, surveillance and the index calculator want every book event within microseconds, 345 Mbit/s at peak. How do you deliver it?”
Your move. Pick an approach:
Deep dive 5 of 6
Interviewer
“Someone types 1,000,000 shares instead of 1,000, or a price slides inside its band. How do you stop it without slowing the hot path?”
Your move. Pick an approach:
Deep dive 6 of 6
Interviewer
“5,000 symbols, a 2 million a second design peak, and 500,000 a second per engine thread. How do you spread the symbols?”
Your move. Pick an approach:
Build-up · 7 steps
Follow one ACME order through it
Only steps 1 to 4 sit on the latency-critical path; market data, clearing and control work from the ordered log on either side of it.
Step 1 of 7
Enter
The gateway runs stateless checks — tick, lot, quantity cap, band, fat-finger notional, message rate — in parallel, and rejects bad orders before they cost the core anything.