# Push Notification Service \
\
---\
\
0) Problem Restatement\
Design a scalable push notification service that can send notifications to millions of users across multiple platforms (iOS, Android, Web) with high throughput, low latency, and guaranteed delivery. Core challenges include handling massive fan-out (one message to millions of devices), respecting rate limits from platform providers (APNs, FCM), and ensuring reliability despite failures.\
\
1) Requirements\
\
1.1 Functional\
- Send push notifications to users on iOS, Android, and Web.\
- Support multiple notification types: transactional (order updates), promotional (offers), social (friend requests).\
- Target individual users, user segments, or broadcast to all users.\
- Schedule notifications for future delivery.\
- Track delivery status (sent, delivered, clicked, failed).\
- Support rich notifications (images, actions, deep links).\
- Allow users to manage notification preferences.\
- Provide analytics (delivery rate, click-through rate).\
1.2 Non-Functional\
- High Throughput: Send millions of notifications per second.\
- Low Latency: Deliver critical notifications within seconds.\
- Reliability: Guaranteed delivery with retries and fallbacks.\
- Scalability: Handle 1 billion+ registered devices.\
- Rate Limiting: Respect provider limits (APNs, FCM).\
- Availability: 99.9% uptime.\
- Deduplication: Prevent duplicate notifications.\
- Prioritization: Critical alerts delivered before promotional content.\
1.3 Scale Estimates\
- Registered devices: 1 billion devices (500M iOS, 400M Android, 100M Web).\
- Daily notifications: 10 billion notifications/day.\
- Peak throughput: 200K notifications/second (major events, flash sales).\
- Provider rate limits:\
- APNs: ~5000 connections, ~500 notifications/sec per connection.\
- FCM: No published limit, but rate limiting exists.\
- Avg notification size: 1 KB (including payload).\
- Storage: 10B notifications/day × 1 KB × 30 days retention = 300 TB/month.\
1.4 API Design\
The core APIs required for the service:\
- Send Notification:
POST /notify- Send to specific user(s).\ - Broadcast Notification:
POST /broadcast- Send to all users.\ - Notify Segment:
POST /notify-segment- Send to specific segment.\
---\
\
2) High-Level Architecture\
\
2.1 Overview\
- Client Apps → API Gateway → Notification Service → Fan-Out Service → Provider Workers (APNs, FCM) → Platform Providers → User Devices.\
- Key components: Fan-out for segment/broadcast, rate limiter per provider, retry queue, analytics pipeline.\
2.2 Architecture Diagram\
```mermaid\
---\
config:\
layout: elk\
---\
flowchart TB\
%% Sender initiates notification\
Sender[\