SYSTEM DESIGN SKETCHBOOK / PRACTICE SHEET / NO. 44
Design global live stock price distribution
A retail investing app shows live prices on watchlists and on each stock's page, for users on phones and browsers in North America, Europe and Asia. Prices come from several exchange feeds. Users want the number on screen to be current and to move when the market moves.
Requirements
- Show last trade price, change from previous close, and best bid and ask for any of 10,000 listed symbols, updating live while on screen.
- A watchlist of up to 50 symbols updates live; opening a symbol page shows a correct price immediately, then live updates.
- A client never shows an older price after a newer one for the same symbol.
- Show a clear stale indicator when updates for a symbol stop arriving during market hours.
Constraints and assumptions
- Six exchange feeds totalling 500,000 updates/s at the market open and about 50,000/s on average; the 100 busiest symbols produce 40% of updates.
- 5M concurrently connected clients at peak across three continents, each subscribed to about 20 symbols.
- Latency from feed receipt to screen: p99 under 500 ms in the same region, under 1 s worldwide.
- Display only: no trading on these prices, and nobody can read more than a few changes per second per symbol, so clients do not need every tick.
Out of scope for the first sketch
Order entry and execution · Historical charts · Full order book depth · Options and other derivatives
Draw your design
Rough math and notes
SYSTEM DESIGN SKETCHBOOK / FOLLOW-UPS
Design global live stock price distribution
Finish your first sketch before answering these. Cross out freely.
- The busiest symbol updates 2,000 times a second at the open. What does a phone watching it actually receive?
- A client connects, or reconnects after a train tunnel. How does it get a correct current price without a gap or a step backwards?
- How do updates reach 5M connections on three continents without the core sending 5M copies of each one?
- One exchange feed handler crashes and its standby takes over. What do clients see during the switch?
- Free users must see prices delayed by 15 minutes while paying users see real time. Where does that split happen, and how do you make sure it cannot leak?
Compare afterwards: worked approaches and reading at sketchbook /questions/stock-price-feed/review