Crypto Exchange (CEX) Development
A centralized crypto exchange is the most complex product in crypto infrastructure. Matching engine, custody system, compliance layer, market data, liquidity — everything must work simultaneously, reliably and under load. I'll explain how this works internally and what's really needed to launch a serious platform.
System Architecture
High-Level Schema
Client Layer
├── Web Trading Terminal (React/Vue)
├── Mobile Apps (iOS/Android)
└── API (REST + WebSocket + FIX)
│
API Gateway / Load Balancer
│
Service Layer
├── Auth Service (JWT + 2FA)
├── Order Service → OMS
├── Account Service → Balances
├── Market Data Service → Feeds
└── Notification Service
│
Core Infrastructure
├── Matching Engine (C++/Rust/Go)
├── Risk Engine
├── Custody System
└── Settlement Engine
│
Data Layer
├── PostgreSQL (accounts, orders, trades)
├── Redis (order book state, sessions)
├── Kafka (event streaming, audit log)
└── TimescaleDB (OHLCV, market data)
Service Isolation Principle
Each service is independent and communicates through events (event-driven). Matching engine doesn't know about users — it only knows about orders. Account service doesn't know about trading — it knows about balances.
This is important for several reasons:
- Independent scaling: matching engine on separate bare metal, everything else on Kubernetes
- Fault isolation: notification service failure doesn't affect trading
- Independent deployment without downtime
Matching Engine
Performance Requirements
Matching engine is the only component where performance is existential. Latency >10ms is real losses for HFT clients and market makers.
| Tier | Throughput | Latency (order-to-ack) | Technology |
|---|---|---|---|
| Startup (<$1M/day) | 1,000 ops/sec | <50ms | Go / Java |
| Mid-tier ($1-50M/day) | 10,000 ops/sec | <5ms | Go / Rust |
| Large ($50M+/day) | 100,000+ ops/sec | <500µs | C++ / Rust |
Order Book Implementation
See detailed implementation examples in the Rust code structure with BTreeMap for fast operations and price level management.
Custody System
Custody Architecture
Exchange stores user funds. This is huge responsibility: history knows dozens of exchange hacks (Mt.Gox, Bitfinex, FTX). Correct storage architecture is not optional but basic requirement.
Multi-sig cold storage:
- 95%+ funds in cold wallets
- Sign transactions on air-gapped machines
- 3-of-5 or 5-of-7 multisig scheme
- Physically distributed keys (different data centers, countries)
- Hardware Security Modules (HSM) for key holders
Hot wallet:
- 2-5% funds for operational withdrawals
- Automatic refill from cold when balance drops below threshold
- Daily withdrawal limit: manual approval if exceeded
KYC/AML and Compliance
Verification Levels
| KYC Level | Data | Daily Limit |
|---|---|---|
| 0 — Email | Email only | 0 (view only) |
| 1 — Basic | Phone + country | $500 |
| 2 — Standard | ID + Selfie | $10,000 |
| 3 — Enhanced | Proof of address + source of funds | $100,000 |
| Institutional | Corporate documents | Unlimited |
Integration with Sumsub or Onfido via REST API. Webhook on verification status change.
Market Data System
Real-Time Feeds
Market data is what trader sees: book, candles, last price, volume. At thousands of subscribers this is serious load.
WebSocket server publishes diff updates (delta, not full book on each change). Client keeps local copy and applies deltas — this reduces traffic 10-50x.
Operational Questions
Liquidity Bootstrap
Exchange without liquidity is dead. Startup options:
- Aggregated liquidity: connect Binance/OKX as liquidity source via market making bot
- Designated Market Makers: agreement with professional MM companies (Jump, Wintermute, GSR)
- Liquidity mining: users adding liquidity via limit orders receive exchange token
Infrastructure and Scaling
| Component | Infrastructure | Cost/month |
|---|---|---|
| Matching Engine | Bare metal (32-core, 128GB RAM) | $2,000-5,000 |
| API servers | Kubernetes (10-50 nodes) | $5,000-20,000 |
| Databases | Managed PostgreSQL cluster | $1,000-5,000 |
| CDN + DDoS protection | Cloudflare Enterprise | $2,000-10,000 |
| HSM (cold storage) | AWS CloudHSM | $1,500/month |
Minimum infrastructure budget: $15,000-50,000/month for serious exchange. Plus team: minimum 8-12 engineers. Development timeline from scratch: 12-24 months.







