Messaging & Realtime · Medium
Design a Real-Time Notification System
Drag a component from the left onto the canvas
Scenario brief
Goal
Design a real-time notification system: events (likes, messages, alerts) fan out to users quickly via push (WebSocket/SSE) and optional email/push later.
Functional requirements
- Producers publish notification events (e.g. “user X liked your post”).
- Online users receive near-real-time push on an open connection.
- Persist notifications so users can read history when they come back online.
Non-functional requirements
- Low latency for online push (seconds matter).
- Handle fan-out: one event may notify many recipients.
- Don’t block the main API write path on slow delivery — use async.
Scale assumptions
Assume ~5M DAU, ~20 notifications generated per user/day on average → ~100M notifications/day. Peaks several× higher.
Your canvas task
Show async fan-out: Client → Gateway/LB → App → Queue; Client → Realtime Gateway for online push; DB stores history.
Capacity check (optional)
Optional — 2 quick estimates from the scale above. Skip anytime; skipping does not fail you, it only skips a small bonus.
1.~5M DAU × ~20 notifications/user/day. About how many notifications/day?
2.~100M notifications/day averaged over 86,400s. About how many notifications/second?