High-Performance Perpetual Futures Exchange Matching Engine
High-Performance Perpetual Futures Exchange Matching Engine
A production-ready perpetual futures exchange matching engine with nanosecond-level latency, featuring advanced optimizations including memory pooling, lock-free data structures, SIMD acceleration, and optimized persistence.
See PERFORMANCE_BENCHMARK_REPORT.md for detailed performance comparison.
Key Optimizations:
Performance Results (vs Original):
# Quick test (10K orders)
./run_benchmark.sh 10000
# Full test (50K orders)
./run_benchmark.sh 50000
# Or run directly
cd build && ./comprehensive_performance_comparison 10000…┌─────────────────┐
│ API Gateway │
└────────┬────────┘
│
┌────┴────┐
│ │
┌───▼───┐ ┌──▼──────┐
│Trading│ │Matching │
│Service│ │ Service │
└───┬───┘ └───┬─────┘
│ │
└────┬────┘
│
┌────▼───────────────┐
│ Production │
│ Components │
│ - Auth │
│ - Liquidation │
│ - Funding Rate │
│ - Market Data │
│ - Notification │
│ - Database │
│ - Monitoring │
└────────────────────┘# Clone repository
git clone https://github.com/lanpishu6300/matching-engine.git
cd matching-engine
# Build
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . -j$(nproc)
# Or use Makefile
make build# Prepare configuration
cp config.ini.example config.ini
# Edit config.ini as needed
# Run
cd build
./production_server ../config.ini# Build production image
make docker-build
# Run with Docker Compose
docker-compose -f docker-compose.production.yml up -dSee config.ini.example for all configuration options:
# Logging
log.level=INFO
log.file=logs/exchange.log
# Rate Limiting
rate_limit.global_orders_per_second=10000.0
rate_limit.per_user_orders_per_second=1000.0
# Persistence
persistence.enabled=true
persistence.db_path=./data
persistence.buffer_size=10000
persistence.flush_interval_ms=100# Use the benchmark script
./run_benchmark.sh 10000
# Or run directly
cd build
./comprehensive_performance_comparison 10000 # All versions comparison
./quick_benchmark # Quick test (10K orders)
./full_benchmark # Full benchmark
./persistence_benchmark # Persistence performanceSee PERFORMANCE_BENCHMARK_REPORT.md for detailed results.
Summary:
This project includes all production-grade features:
[Add your license here]
No open issues yet, or sync has not completed.