1M/s
order messages a second just after the open
2 billion a day over 5,000 symbols. One engine thread is budgeted 500,000 a second, so design for 2 million across 8 engines.
B9 buys 1,000 at up to ₹1,000.15. Who sells?
Cheapest ask first, oldest first within a price, at the resting order’s price. 800 fill at an average ₹1,000.13; 200 rest as the best bid.
How many threads should match?
Bad: Many threads, one lock
They take turns at the lock, and the OS picks who trades.
Good: One thread per partition
No locks or I/O: LMAX did 6 million orders a second.
Two orders reach two gateways at once. Who came first?
Not the member’s clock, nor each gateway’s. The sequencer gives every input the next number, journals it and copies it to a standby before matching.
The primary matches #1042, then dies before replying. Members are still waiting for fills.
The trick
The standby applied #1042 from the same log, outputs muted. Its books are identical; it just sends the fills.
1,000 subscribers want every event within microseconds
A TCP stream each would be 345 Gbit/s. UDP multicast sends each packet once; sequence numbers expose gaps, and a re-request server refills them.
Someone types 1,000,000 shares instead of 1,000
- Gateway checks tick, quantity cap, band and notional
- The engine checks halts and dynamic bands in order
- Kill switch: disable a port, cancel its orders
Remember
Sequence every input once, copy it to a standby, then match on one deterministic thread. The log is the truth; everyone reads its output.