8000 GitHub - dominictobias/lightfin-engine: Low-latency order matching engine in Rust with deterministic replay, Raft failover, venue SDKs. It reached 446k committed commands/s on three EC2 nodes with WAL data sync and both feeds enabled. Spot settlement is available today. Venue-managed derivatives are planned. · GitHub
[go: up one dir, main page]

Skip to content

About

Low-latency order matching engine in Rust with deterministic replay, Raft failover, venue SDKs. It reached 446k committed commands/s on three EC2 nodes with WAL data sync and both feeds enabled. Spot settlement is available today. Venue-managed derivatives are planned.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

58 Commits

Folders and files

Repository files navigation

Lightfin Engine

Lightfin is a low-latency order matching and execution engine written in Rust. A single writer handles price-time priority matching across markets. Each sequenced command records its complete outcome in the write-ahead log (WAL), and recovery applies the same recorded transitions as the live engine.

Lightfin is pre-alpha and under active development. The wire protocol, configuration, and on-disk formats may change. See the development roadmap.

What it supports

  • Limit and protected market orders with GTC, IOC, or FOK where applicable, plus post-only limit orders and cancel-newest self-trade prevention.
  • Standalone operation or a three-node Raft cluster with automatic leader failover. Acknowledgements and feed events wait for local commit in standalone mode and quorum commit in a cluster.
  • FIX Simple Binary Encoding (SBE) over UDP for trusted venue gateways, with sequenced public market-data and private account feeds. The venue SDKs provides command batching, retries, leader discovery, and a transactional outbox.

Lightfin currently handles balance reservations and settlement for spot trades. For planned derivatives support, Lightfin will sequence and match orders and publish replayable executions. The venue will implement pre-trade risk, positions, collateral, and settlement. Derivatives roadmap

The venue gateway handles user authentication, rate limits, and any public REST, WebSocket, or FIX API. Gateway protocol

Measured on Amazon EC2

The 2 December 2026 benchmarks ran on three c6id.2xlarge instances in one cluster placement group in us-east-1a, with local NVMe WAL storage and checkpoints every two seconds. The load generator ran on the leader and alternated resting limit orders with orders that fully filled them. It measured throughput and latency from command acknowledgements after inter-host Raft quorum commit.

Benchmark configuration WAL sync Committed commands/s Send-to-commit p99.9
Feeds disabled, experimental host tuning page-cache 750,408–781,879 3.56–5.49 ms
Packed public and private feeds page-cache 487,911–504,762 9.64–9.90 ms
Packed public and private feeds data 446,375 18.36 ms

All rows used 1,024 commands in flight. The two page-cache rows each summarize two runs, while the data row shows one run. With one command in flight, CPU isolation, feeds disabled, and page-cache sync, median send-to-commit latency was 115–117 µs. EC2 measurements · Benchmark runbook

The default data mode forces WAL data to storage on a quorum before acknowledgement. In page-cache mode, a quorum can acknowledge from the OS page cache, so some host or power failures can lose acknowledged commands. Durability model

Run locally

Install Rust with Cargo and the Protocol Buffers compiler (protoc). The venue example also requires Go 1.26 or newer.

From the repository root, start a standalone engine with both feeds enabled.

cd lightfin_engine
cargo run --release -p lightfin-server -- \
  --config config/venue.example.toml --data-dir ./data/quickstart \
  --bind 127.0.0.1:9000 --market-data 127.0.0.1:9101 \
  --private-data 127.0.0.1:9102

In a second terminal at the repository root, run the example gateway. It funds two accounts, crosses a BTC/USD order, and prints the trade, fills, and balances.

cd venue_go_example
go run . --engine 127.0.0.1:9000 --outbox ./venue.outbox

Run the Rust test suite with cargo test --workspace --release from lightfin_engine/ and the SDK tests with go test ./... from sdk/go/.

Documentation

About

Low-latency order matching engine in Rust with deterministic replay, Raft failover, venue SDKs. It reached 446k committed commands/s on three EC2 nodes with WAL data sync and both feeds enabled. Spot settlement is available today. Venue-managed derivatives are planned.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0