Same price, a microsecond apart: who was first?
transcript
Two orders. Same contract. Same price. A microsecond apart. Five million messages a second. So who was first?
Sort by timestamp? Gateway clocks differ by microseconds. And two clocks can tie. Then who's first? So one sequencer stamps every message with the next number. Whatever it numbers first is first. The number is the clock.
Orders from every gateway meet at one sequencer. It numbers them, and writes them to a journal. One thread applies them, in that exact order. Trades come out. No locks, because nothing is shared.
But here's the catch. Why not four threads and a lock? Lock order isn't arrival order. Run it twice, get different trades.
One sequencer per partition. Zero clocks inside the engine. Even the 3:30 close is a sequenced event. Same log in, same trades out. Every time.
Crash? Replay the log, and you get the same book. First isn't a time. It's a number.
Full breakdown in the lecture.