Skip to content

river-zuo/rust-dex

Repository files navigation

Rust DEX Trading System

Rust License Build Status Performance Latency

一个高性能、低延迟的Rust交易系统,支持高并发订单处理。

🚀 快速开始

5分钟快速测试

# 1. 构建系统
make build-release

# 2. 启动系统
make run-background

# 3. 运行测试
make quick-test

# 4. 查看结果
make status

详细步骤请参考 QUICK_START.md

📚 文档

测试文档

开发文档

🎯 性能目标

  • 吞吐量: 20万订单/秒
  • 延迟: 微秒级响应
  • 并发: 支持数千并发连接
  • 稳定性: 7x24小时稳定运行

📊 当前性能

测试场景 客户端数 吞吐量 平均延迟 状态
小规模 5 ~1,000 订单/秒 ~100μs
中等规模 10 ~3,600 订单/秒 ~680μs
大规模 50 ~14,500 订单/秒 ~1,150μs

🛠️ 技术栈

  • 语言: Rust
  • 异步运行时: Tokio
  • 网络: TCP with TCP_NODELAY
  • 数据结构: DashMap, BTreeMap, Crossbeam
  • 序列化: Serde JSON
  • 监控: 自定义指标收集

📋 功能特性

核心功能

  • ✅ 订单匹配引擎
  • ✅ 实时订单簿
  • ✅ 市场数据推送
  • ✅ 高性能网络层
  • ✅ 内存池管理
  • ✅ 监控和指标

高级特性

  • 🔄 异步处理
  • 🔒 内存安全
  • 📈 性能监控
  • 🔧 配置管理
  • 📊 指标收集

🧪 测试

快速测试

# 基础功能测试
make quick-test

# 性能测试
make perf-test

# 压力测试
make stress-test

详细测试

# 查看所有测试命令
make help

# 运行完整测试套件
make full-test

# 自定义性能测试
cargo run --example performance_test -- --clients 10 --orders-per-second 2000 --duration 5

📈 监控

系统监控

# 查看系统状态
make status

# 查看实时日志
make logs

# 完整监控信息
make monitor

性能指标

  • 订单处理速率
  • 交易执行延迟
  • 内存使用情况
  • 网络连接状态

🔧 配置

系统通过 config.json 进行配置:

{
  "engine": {
    "matching_threads": 16,
    "order_queue_size": 1000000,
    "trade_queue_size": 100000
  },
  "network": {
    "host": "0.0.0.0",
    "port": 8080,
    "max_connections": 10000
  },
  "metrics_port": 9090
}

🚀 部署

本地部署

# 构建生产版本
make build-release

# 后台启动
make run-background

# 验证部署
make status

Docker部署

# 构建镜像
docker build -t rust-dex .

# 运行容器
docker run -p 8080:8080 -p 9090:9090 rust-dex

📞 支持

获取帮助

# 查看所有命令
make help

# 查看系统信息
make info

# 查看测试脚本帮助
./scripts/quick_test.sh --help

故障排除

  • 查看 测试指南 中的故障排除部分
  • 检查系统日志: make logs
  • 验证系统状态: make status

🤝 贡献

欢迎提交 Issue 和 Pull Request!

开发环境设置

# 克隆项目
git clone <repository-url>
cd rust-dex

# 安装依赖
cargo build

# 运行测试
make test

📄 许可证

MIT License

📊 性能基准

详细的性能测试结果请参考 PERFORMANCE_REPORT.md


提示: 首次使用建议先阅读 QUICK_START.md 进行快速测试。

About

rust版本的DEX交易系统

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published