Zerodha HLD: The Matching Engine at the Heart of a Stock Exchange
A stock exchange system design (Zerodha): a limit order book with price-time priority, the matching algorithm, an in-memory engine kept durable by a journal, and correctness over availability.
It's 9:15 on a Tuesday, the kettle is on, and you tap BUY — 50 shares, limit ₹101.00. Before you've put the phone down the app says filled 40 at ₹100.85, 10 resting. You never asked for ₹100.85. You asked for ₹101.00 or better — and in the few hundred microseconds between your thumb and that line of text, a machine decided which stranger had been waiting longest at the best price, paired the two of you, filled you at their number rather than yours, and parked your leftover 10 shares in a queue where they'll wait their turn. That machine is the matching engine, and it is the whole of "Design Ze…
What’s inside
Read this one free
Sign in and your first premium article is on us — read Zerodha HLD: The Matching Engine at the Heart of a Stock Exchange free.