← Back to All Questions
Easy~35 minReal-Time Systems

Design Stock Prices Streaming Service

BloombergRobinhoodE*TRADEYahoo FinanceGoogle

πŸ“ Problem Description

Design a real-time stock price viewing service that streams live prices to millions of users. Show current prices, price changes, charts, and support watchlists. Handle high-frequency updates during market hours.

πŸ‘€ Use Cases

1.
User wants to opens stock page so that sees live price updating in real-time
2.
User wants to views watchlist so that sees all watched stocks with live prices
3.
User wants to views chart so that sees historical and real-time price chart
4.
System wants to receives market data so that broadcasts to all subscribed users

βœ… Functional Requirements

  • β€’Real-time stock price streaming
  • β€’Price change ($ and %) from open
  • β€’Bid/ask prices and volume
  • β€’Intraday, 1W, 1M, 1Y charts
  • β€’Watchlists with multiple stocks
  • β€’Search for stocks by symbol/name
  • β€’Price alerts

⚑ Non-Functional Requirements

  • β€’Price update latency < 100ms from exchange
  • β€’Support 10M concurrent users during market hours
  • β€’Handle 10K price updates per second
  • β€’99.9% availability during market hours

⚠️ Constraints & Assumptions

  • β€’Market data licenses required
  • β€’Updates only during market hours
  • β€’Historical data for charting needed

πŸ“Š Capacity Estimation

πŸ‘₯ Users
10M concurrent during peak hours
πŸ’Ύ Storage
100GB for historical prices + real-time buffer
⚑ QPS
Inbound: 10K updates/sec, Outbound: 10M WebSocket connections
🌐 Bandwidth
50TB/day during market hours
πŸ“ Assumptions
  • β€’ 10K ticker symbols
  • β€’ Updates every 100ms during trading
  • β€’ 10M concurrent users watching prices
  • β€’ Average user watches 10 stocks

πŸ’‘ Key Concepts

CRITICAL
Pub/Sub for Price Distribution
Use Kafka topics per symbol for scalable fan-out.
CRITICAL
WebSocket Fan-out
Maintain millions of WebSocket connections with subscription management.
HIGH
Time-Series Storage
Store OHLCV data for charting in InfluxDB or TimescaleDB.
HIGH
Throttling
Batch rapid updates to reduce client message frequency.

πŸ’‘ Interview Tips

  • πŸ’‘Start with the real-time streaming architecture
  • πŸ’‘Discuss the fan-out pattern for subscriptions
  • πŸ’‘Emphasize the low-latency requirements
  • πŸ’‘Be prepared to discuss time-series storage
  • πŸ’‘Know the tradeoffs between push and pull
  • πŸ’‘Understand the market data feed structure