Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

3) Make it distributed

For order books, “distributed” is usually not peer-everywhere consensus.

It is typically replication around a single leader sequencer:

  • leader assigns sequence numbers to every command,
  • followers replay the exact same command log,
  • market data is published from sequenced events.

Distribution model

  • Control plane: leader election/failover policy.
  • Data plane: command log replication and replay.
  • Fanout plane: market data pub/sub (gRPC stream, broker, or demo pubsub).

Reliability knobs at the edge

Apply tower middleware around the client-facing API:

  • timeout slow requests,
  • shed load under pressure,
  • rate-limit abusive clients.

Try it: 1 leader + 1 follower

cargo run -p orderbook_node -- --role leader --id ob1 --log ./ob1.log
cargo run -p orderbook_node -- --role follower --id ob2 --follow ./ob1.log

Submit a small order flow to leader, then kill leader, restart follower with replay, and verify state rebuild from the append-only log.

Deliverable

A demo where follower rebuilds full book state and continues serving market data from replayed events.