System Design: Real‑Time Stock Prices Viewer (No History)
You are designing a real‑time system that lets clients view current stock prices only. No historical queries are supported.
Assume:
-
Real‑time view of last trade price and top‑of‑book (best bid/ask) per symbol.
-
Multiple upstream market feeds (e.g., SIP and/or direct exchange feeds).
-
Millions of concurrent end users with watchlists.
Describe and justify a design that covers:
-
Ingestion and Processing
-
Ingesting market data feeds (parsing, sequencing, network considerations).
-
Symbol normalization and reference data management.
-
Deduplication and out‑of‑order handling.
-
Aggregation (per‑venue books, cross‑venue top‑of‑book, last trade).
-
Client Dissemination
-
Transport and pub/sub choices (e.g., WebSockets vs. SSE vs. long polling).
-
Fan‑out strategy and edge distribution.
-
Caching current values for fast snapshots.
-
API and Controls
-
API design for initial snapshot and live updates.
-
Throttling and quotas (per connection, per symbol, message rates).
-
Performance and Reliability Goals
-
Latency and consistency targets.
-
Backpressure policy and delivery semantics to clients.
-
Horizontal scaling to millions of concurrent users.
-
Resilience and Operations
-
Fault tolerance, failover, and multi‑region active/active deployment.
-
Monitoring, alerting, and on‑call runbooks.
-
Testing strategies (including load tests and simulators).
Keep the scope to real‑time only (no historical query capabilities). State reasonable assumptions where needed and explain trade‑offs.