📝 Problem Description
Design a scalable notification service that can deliver messages across multiple channels including push notifications (iOS/Android), email, SMS, and in-app notifications. The system should handle billions of notifications daily with reliable delivery, user preferences, and rate limiting.
👤 Use Cases
1.
Application wants to send a notification to a user so that user receives it on their preferred channel
2.
User wants to set notification preferences so that they only receive notifications they want
3.
Marketing wants to send bulk campaign so that millions of users receive personalized messages
4.
System wants to retry failed delivery so that notification is eventually delivered
5.
User wants to unsubscribe from emails so that they stop receiving that type of email
✅ Functional Requirements
- •Send notifications via push (iOS/Android), email, SMS, in-app
- •Support notification templates with personalization
- •User preference management (channel, frequency, types)
- •Scheduling: send immediately or at specific time
- •Bulk/batch notification sending
- •Delivery tracking and analytics
- •Unsubscribe/opt-out handling
- •Priority levels (critical, high, normal, low)
⚡ Non-Functional Requirements
- •Handle 10 billion notifications per day
- •Delivery latency < 1 second for high priority
- •At-least-once delivery guarantee
- •99.99% availability
- •Rate limiting per channel (email limits, SMS costs)
- •GDPR/CAN-SPAM compliance
⚠️ Constraints & Assumptions
- •Push notification payload: 4KB (iOS), 4KB (Android)
- •Email: respect sending limits per domain/IP
- •SMS: 160 characters, expensive
- •Rate limit: avoid being flagged as spam
- •Honor user time zones for scheduled notifications
📊 Capacity Estimation
👥 Users
500M users with notification preferences
💾 Storage
100TB for notification history and templates
⚡ QPS
100K notifications/sec peak
📐 Assumptions
- • 10 billion notifications per day
- • 70% push, 25% email, 5% SMS
- • Peak: 3x average during events
- • Average user receives 10 notifications/day
- • 5 device tokens per user average
💡 Key Concepts
CRITICAL
Fan-out
Single notification request expands to multiple channels and devices. Router orchestrates this expansion.
CRITICAL
At-least-once Delivery
Use Kafka for durability. Retry failed deliveries. Idempotency keys prevent duplicates.
HIGH
Rate Limiting
Per-user limits (no spam), per-channel limits (ESP quotas), global limits (cost control).
HIGH
Token Management
Push tokens expire/change. Handle token refresh, removal of invalid tokens.
MEDIUM
Template Engine
Separate content from delivery. Templates support personalization and localization.
HIGH
Preference Center
Users control what they receive. Critical for compliance (GDPR, CAN-SPAM).
💡 Interview Tips
- 💡Start with the notification pipeline: trigger → process → deliver
- 💡Discuss multi-channel delivery early
- 💡Emphasize user preferences and rate limiting
- 💡Be prepared to discuss push notification providers (FCM, APNs)
- 💡Know the tradeoffs between real-time and batched delivery
- 💡Understand template rendering and personalization