Design a Cryptocurrency Trading System with Third-Party Exchanges
CoinbaseSoftware Engineer · OnsiteLast updated
This interview question evaluates requirements, scale assumptions, API/data design, architecture, trade-offs, failure modes, and rollout in a realistic interview setting. A strong answer for Design a Cryptocurrency Trading System with Third-Party Exchanges states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.
Question
Design a cryptocurrency trading platform that routes client orders to one or more third-party exchanges that expose a (nominally) synchronous HTTP order/cancel API. Even though the venue API looks synchronous, fills and cancellations are effectively asynchronous and arrive later via polling, webhooks, or streams.
Address the following:
- Overall architecture. Lay out the services, databases, messaging/event bus, and per-exchange connectors. Explain why you offer the client a fast synchronous "accepted" response while real execution happens asynchronously behind the scenes, and how you decouple order submission from fills/cancellations.
- Order lifecycle / state machine. Define the full state-transition diagram for an order (e.g.,
NEW → PENDING_SUBMISSION/PARTIALLY_FILLED → FILLED / CANCELED / EXPIRED / REJECTED, plus an explicit "unknown outcome" state). Specify the allowed transitions, how you persist and recover state, and how you keep transitions idempotent. - Timeouts, partial failures, and exactly-once effects. Explain how the system detects and recovers from third-party exchange timeouts or failures using retries, idempotency keys / client order IDs, deduplication, circuit breakers, dead-letter queues, and reconciliation. Describe how you avoid double execution and approximate exactly-once external effects.
- Spiky traffic. Propose strategies (rate limiting, queueing, backpressure, autoscaling, batching, circuit breakers, hot-shard mitigation) to absorb bursty load and protect both your own services and the downstream exchanges' published rate limits.
- Data consistency & durability. Specify the consistency and durability guarantees for orders, trades/fills, and user balances (e.g., a double-entry ledger with reserve → settle/release), and how internal strong consistency coexists with eventual consistency against the exchange's truth.
- Multi-exchange routing (optional). If a single parent order can be split across venues, describe the smart order router (SOR), parent/child order modeling, and how child fills aggregate into the parent state.
- Client APIs, SLAs, and observability. Define the client-facing REST/streaming APIs, target SLAs/SLOs, and the metrics, tracing, logging, and alerting needed to operate the system.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.