Design a Crypto Exchange like Coinbase
Understanding the Problem
🪙 What is a crypto exchange? A centralized crypto exchange like Coinbase, Kraken or Binance lets users deposit dollars or cryptocurrency, trade one asset for another, and withdraw to a bank or to a blockchain address. It's custodial: the exchange holds the private keys for the coins, and each user's balance is a number in the exchange's own ledger. Trades between users happen in that ledger, off-chain, and only deposits and withdrawals touch a blockchain.
It helps to see this as three systems glued together by a ledger. A brokerage (sign up, deposit, "buy $100 of Bitcoin"), an exchange (an order book and matching engine per trading pair, like a stock exchange), and a custodian (wallets, keys, and the machinery that moves coins on real blockchains). Interviewers usually pick one of these to go deep on, so it's worth naming all three early and asking which one they care about most.
Functional Requirements
Core Requirements
- Users should be able to deposit crypto from an external wallet (and fiat from a bank), and see it credited to their balance.
- Users should be able to buy and sell crypto, either with a simple "buy $100 of BTC" flow or by placing limit and market orders on an order book.
- Users should be able to withdraw crypto to an external address, and send crypto to another user of the exchange.
- Users should be able to see their balances and transaction history.
Below the line (out of scope)
- Identity verification (KYC) and anti-money-laundering screening in detail. We'll assume an approved account and a screening API.
- Staking, lending, derivatives and margin trading.
- Charts and live market data beyond what the matching engine publishes. These work the same as for stocks (see /system-design/stock-brokerage).
- Running our own blockchain. We integrate with existing ones.
Non-Functional Requirements
Ask about scale and, more importantly, about risk. A reasonable set: 50 million accounts, 5 million daily active users, 300 trading pairs across 50 blockchains, and peaks of 100,000 orders per second on the matching engines during volatile moments. Customer assets held: tens of billions of dollars.
Core Requirements
- Security above everything. No single person, server or bug should be able to move customer funds. A stolen private key is unrecoverable; there is no chargeback on a blockchain.
- Balances must be exactly right. Every unit of every asset is accounted for: what users own in our ledger must equal what we hold on-chain, at all times.
- 24/7 availability. Crypto markets never close, so there's no overnight maintenance window and no opening bell to pre-scale for.
- Low-latency matching (well under a millisecond in the engine) for active traders, with strict ordering and determinism.
- Deposits should be credited as soon as they are safe (seconds to tens of minutes depending on the chain), and withdrawals should be sent within minutes for normal amounts.
Below the line (out of scope)
- Sub-microsecond, co-located trading. Crypto exchanges serve most traders over the public internet.
- Regulatory reporting pipelines in detail.
The numbers that change the design are about blockchains, not about us. Bitcoin produces a block roughly every 10 minutes, and a payment is conventionally considered safe after several blocks, so a Bitcoin deposit can't be credited in a second no matter how fast our servers are. Ethereum produces a block every 12 seconds and reaches finality in roughly 13 minutes. Other chains finalize in seconds. So "credit a deposit" is not one rule; it's a policy per chain.
Withdrawals are small in volume but huge in value. If 2% of daily users withdraw, that's 100,000 withdrawals per day, about one per second on average. That's a trivial request rate. But each one moves real money irreversibly, so each one goes through risk checks and a signing step that's deliberately hard to access.
The central insight to say early: trades never touch the blockchain. When Alice buys 1 BTC from Bob on our exchange, no coins move on-chain. Two rows in our ledger change. The blockchain only sees money entering and leaving the exchange. That's why the exchange can match 100,000 orders a second while Bitcoin handles a handful of transactions per second worldwide.