Design a Live Stock Prices
Design a service that shows the latest stock prices to people around the world. A user opens a watchlist or a stock page in a web or mobile app and sees prices, the change since yesterday’s close and a small chart, all moving as trades happen. Prices come from about 80 exchanges, from New York to Tokyo, through data feeds we license.
At the US market open, 10 million viewers are connected at once, each watching about 20 symbols, while exchanges send 600,000 price updates a second. The hard parts are the fan-out (one tick in Apple must reach millions of screens), freshness (a price must reach a screen in Sydney within half a second of the trade in New York), the bursts at each market open, and staying correct: prices for one symbol must never go backwards because two updates arrived out of order.
Good questions to ask first
Decide what you would assume for each before you look at ours.
- 1Which instruments?
- 2How fresh must a price be?
- 3Must every tick be shown?
- 4How many viewers?
- 5Do users need history?
- 6Is everyone entitled to real-time data?
- 7Which clients?
- 8Can users trade?
How to spend the 45 minutes
- 5minPart 1: Requirements and scope
- 5minPart 2: Estimates
- 5minPart 3: API and stream protocol
- 15minPart 4: Architecture, stage by stage
- 15minPart 5: Conflation, ingest and trade-offs