System Design: Crypto Trading Platform via Synchronous Third‑Party HTTP APIs
Context
You are designing a trading platform that routes client orders to external cryptocurrency exchanges which expose synchronous HTTP APIs (place/cancel/get). Fills and cancellations occur at the exchanges and must be reflected back to clients reliably and quickly.
Requirements
Design the system and address the following:
-
Overall architecture
-
Services, databases, messaging, and third‑party connectors.
-
Order lifecycle
-
Define the order state machine and transitions.
-
How to persist, replay, and recover state after failures/restarts.
-
Sync vs async
-
Why the flow is effectively asynchronous despite using synchronous HTTP.
-
How to decouple submission from fills/cancellations.
-
Third‑party timeouts and failures
-
Retries, idempotency, deduplication.
-
Circuit breakers, dead‑letter queues, reconciliation.
-
Traffic spikes
-
Rate limiting, backpressure, autoscaling, queueing, batching, hot‑shard mitigation.
-
Data consistency guarantees
-
For orders, trades, and balances.
-
Client‑facing surface
-
APIs, SLAs/SLOs, monitoring/alerting.