Monorepo of a super light order-book I built in <1 week as a hands-on tutorial of what makes up an orderbook.
The goals is to create the simplest PoC that provides a starting point for developing a scalable orderbook back-end.
- ~500 req/sec
- up to 1GB live order-book size
- up to 100 clients per sec (mostly a max-file system constraint)
- Simple orderbook terminal visualizer
All the things it doesn't do:
- No connection to ETH and/or L2 JSON RPC
- No load balancer / Docker containers / middleware
- Nothing other than simple limit-orders
Matching Engine: Python (majority of matching / sorting done via Redis) Orderbook: Redis Server: NodeJS Websocket Visualizer: Simple terminal script
Running bare-bones locally consists of three steps:
- Redis Server:
redis-server path-to/booklet/matching_engine/redis.conf
, useredis-cli --stat
to monitor - Engine:
cd matching_engine
->source venv/bin/activate
->python3 server.py
- Websocket Server:
cd websocket
->node server.js
- Booklet Visualizer:
cd matching_engine
->source venv/bin/activate
->cd test
->python3 terminalBooklet.py
- Mock Clients: load testing, simulations and latency mock clients can be found in
websocket/test
Note: on MacOS there are many system controls preventing large number of socket connections from being open: https://k6.io/docs/misc/fine-tuning-os/ https://socket.io/docs/v4/performance-tuning/