Back to projects

ApexBook — Lock-Free Matching Engine

An HFT limit order book in C++20 with ~200ns latency and 100M+ orders/sec throughput.

~200ns

Latency

100M+/s

Throughput

Zero

Allocations

Problem

Traditional order books suffer from lock contention and heap fragmentation, blowing latency budgets during high-frequency trading.

Architecture

MPSC/SPSC ring buffers feed a lock-free matching core. Cache-line-aligned structures prevent false sharing; a custom object pool avoids OS heap allocation entirely.

Challenges

Engineering Decisions

Tradeoffs

Future Work