Design Groww's Real-Time Stock Price Feed and Portfolio P&L Engine

Problem

Design the system that streams live stock prices to millions of users and computes real-time portfolio P&L.

Requirements

Functional:

  • Live price updates for 5000+ NSE/BSE scrips
  • Per-user portfolio P&L updated in real time
  • Price alerts: notify when stock crosses user-set threshold
  • Historical price charts (1D, 1W, 1M, 1Y)

Non-functional:

  • 15M users, 2M with active sessions at market open
  • Price update latency < 500ms from exchange tick
  • Price alert delivery < 2s

Discussion points

  1. Exchange feed ingestion: FIX protocol → Kafka
  2. Fan-out challenge: 2M users watching RELIANCE simultaneously
  3. WebSocket vs SSE for price delivery
  4. P&L computation: push (per tick) vs pull (on request)
  5. Alert engine: sorted set in Redis keyed by threshold price
added …
LeaderboardSalaryAccount