All blueprints
- 01 Terminology Glossary
- 02 Real-Time Chat (WhatsApp)
- 03 Video Streaming (YouTube)
- 04 Low-Latency Systems
- 05 Ordered Message Queues
- 06 URL Shortener
- 07 Rate Limiter
- 08 Notification System
- 09 News Feed
- 10 Offline Messaging
- 11 Circuit Breaker
- 12 Self-Healing Infrastructure
- 13 Scaling to 5M Users
- 14 Handling 5M Requests
- 15 End-to-End Encryption
- 16 Real-Time React Dashboard
- 17 Fast-to-Slow File Transfer
- 18 Ride-Hailing (Uber, Ola)
- 19 Ticket Booking (BookMyShow)
- 20 Unique ID Generator
Blueprint 08 · 1 diagram
Design a Notification System
Multi-channel notification system
1. Summary
A notification system sends messages to users through many channels: mobile push, SMS, email, and in-app. It must be reliable, must not send duplicates, and must respect user preferences.
2. Requirements
- Support push (APNs, FCM), SMS, email, and in-app channels.
- Support real-time and scheduled notifications.
- Respect user settings and opt-out.
- Do not lose notifications. Do not send duplicates.
- Limit the number of notifications for each user.
3. Architecture
flowchart LR
S1["Order service"] --> API["Notification API"]
S2["Marketing service"] --> API
API --> V["Validate + user preferences"]
V --> TPL["Template service"]
TPL --> Q{"Queue for each channel"}
Q --> QP["Push queue"]
Q --> QS["SMS queue"]
Q --> QE["Email queue"]
QP --> WP["Push workers"] --> APNS["APNs / FCM"]
QS --> WS["SMS workers"] --> SMS["SMS provider"]
QE --> WE["Email workers"] --> SES["Email provider"]
WP --> LOG[("Notification log")]
WS --> LOG
WE --> LOG
SCH["Scheduler"] --> API
4. Flow
- A service sends a notification request with an
idempotency_key. - The API checks the key. If the key exists, the API discards the request.
- The API reads the user preferences and the device tokens.
- The template service creates the message text.
- The API puts one job in the queue for each channel.
- Workers send the job to the third-party provider.
- Workers write the result to the notification log.
- If the send fails, workers retry with exponential backoff.
- After the maximum retries, workers send the job to a dead letter queue.
5. Important design points
- Separate queues for each channel: A slow SMS provider does not delay push notifications.
- Priority: Use a high-priority queue for OTP and security messages. Use a low-priority queue for marketing.
- Rate limit for each user: Do not send too many notifications to one user.
- Provider failover: Configure a second SMS or email provider.
- Tracking: Record sent, delivered, opened, and clicked events.
6. Interview follow-up questions
- How do you send one notification to 10 million users?
- How do you prevent duplicate notifications after a worker crash?
- How do you respect user time zones for scheduled notifications?