Meridian: a test-first matching engine with Raft replication
Meridian is a C++20 limit order book with an order management layer (accounts, idempotent client order ids, risk limits, self-trade prevention, stop orders), an HTTP gateway, and a Raft implementation that replicates both the order book and the order management state. It was built test-first. Each component has a differential fuzz against a simple reference. Each safety check is itself tested by deliberately breaking the code (a mutation test) to see whether the check notices. The results that are solid, meaning reproduced in three runs on one machine, are these. Raft election and log replication show 0 safety violations over 3,600 and 3,000 seeded chaos runs, and all five injected bugs per phase were caught. Pre-vote removes the deposed-leader problem (80 of 80 runs without it, 0 of 80 with it). A replicated order management state machine converges in 300 of 300 seeds under loss, duplication, reordering, crashes and partitions, and four deliberately wrong ways of applying the log are caught in 136 to 291 of 300 seeds. On three real processes over loopback UDP, the cluster survives kill -9 of the leader with identical order books afterwards, in 3 of 3 runs. Separately, the engine's book matched Kraken's own checksum on 12,397 of 12,397 updates of a real recording, but that is a single run. Everything was measured on one WSL2 laptop. Latency numbers are therefore not claimed as benchmarks, and durability was not tested, because fdatasync on this machine returns in 0.4 microseconds and does not reach a disk. Section 7 lists what is not established.
Authors
- Manas Jain
Publication Details
- Journal
- Zenodo (CERN European Organization for Nuclear Research)
- Published
- 2026-11-01
- DOI
- https://doi.org/10.5281/zenodo.23856005
- Primary Topic
- Distributed systems and fault tolerance
- Type
- article
- Field-Weighted Citation Impact
- 0.00