Start Here

Tier 1 · Building Blocks

Scale Reads

Scale Writes

Database Selection

Traffic Control

Consistency & Coordination

Estimation

Tier 2 · Core Systems

Tier 3 · Location & Real-Time

Tier 4 · Infrastructure & Data

Tier 5 · Finance & Commerce

Tier 6 · Advanced & Collaborative

Phase 1 — Clarify & Scope

Interviewer: Design a stock exchange — think NYSE or NASDAQ. What do you want to clarify?

Candidate: This is a complex domain. Key questions:

  1. What types of orders — market orders, limit orders, stop orders?
  2. What's the matching engine model — price-time priority (FIFO)?
  3. What's the throughput requirement — orders per second?
  4. Is this equities only, or also options, futures, crypto?
  5. Latency SLA — HFT firms need microseconds; retail traders need milliseconds?

Interviewer: Equities only. Limit orders and market orders. Price-time priority matching. 100,000 orders/sec peak. Latency: order acknowledgment < 1 ms, trade execution notification < 10 ms. No HFT co-location for now.

Candidate: Let me size this:

Orders/sec=100,000\text{Orders/sec} = 100{,}000

Symbols traded≈5,000 (US equities)\text{Symbols traded} \approx 5{,}000 \text{ (US equities)}

Orders per symbol per sec=100,0005,000=20 orders/symbol/sec average\text{Orders per symbol per sec} = \frac{100{,}000}{5{,}000} = 20 \text{ orders/symbol/sec average}

Order book depth (active price levels)≈1,000 levels per symbol\text{Order book depth (active price levels)} \approx 1{,}000 \text{ levels per symbol}

\text{Trade notifications} \approx 100{,}000 \times 0.3 = 30{,}000 \text{ trades/sec (30% match rate)}

Interviewer: What are the core requirements?

Candidate:

  • Accept limit orders (buy/sell at price ≤/≥ limit) and market orders (execute at best available)
  • Maintain an order book per symbol: sorted bid/ask price levels
  • Match orders in price-time priority: best price first, oldest order at same price first
  • Emit trade execution notifications and order status updates
  • Market data feed: real-time order book state and last trade prices

Non-functional:

  • Order acknowledgment: < 1 ms (order received and validated)
  • Matching…

In the full tutorial

  • Phase 2 — High-Level Architecture
  • Phase 3 — Deep Dive & Evolution
  • Phase 4 — Robustness & Operations

Glossary history

Click dotted jargon to save explanations here.