| Scale | Users | Notifications/Day | Key Changes |
|---|---|---|---|
| Small | 100 | 1,000 | Single server handles API and DB; simple queue; direct push |
| Medium | 10,000 | 100,000 | Introduce message queue; DB read replicas; caching user preferences |
| Large | 1,000,000 | 10,000,000 | Multiple app servers; sharded DB; distributed queue; push notification services |
| Very Large | 100,000,000 | 1,000,000,000 | Global load balancers; multi-region DB shards; CDN for static content; advanced throttling |
Notification system design in HLD - Scalability & System Analysis
Start learning this pattern below
Jump into concepts and practice - no test required
At small to medium scale, the database is the first bottleneck. It struggles with high write volume for notifications and user preferences. As traffic grows, the message queue and application servers also become bottlenecks due to processing and delivery delays.
- Database: Use read replicas for reads, write sharding by user ID, and caching for user settings.
- Application Servers: Horizontally scale with load balancers to handle more concurrent connections.
- Message Queue: Use distributed queues like Kafka or RabbitMQ to handle high throughput and ensure reliable delivery.
- Push Delivery: Integrate with platform push services (APNs, FCM) and use CDN for static notification content.
- Throttling & Batching: Batch notifications and throttle to avoid overwhelming users and systems.
- Requests per second: At 1M users sending 10 notifications/day, ~115 QPS (10M/86400s).
- Storage: Assuming 1KB per notification, 10M notifications/day = ~10GB/day storage.
- Bandwidth: Push payloads are small (~1KB), so 10M notifications ~10GB outbound daily.
- Server capacity: One app server handles ~3000 concurrent connections; scale horizontally as users grow.
- Database QPS: One PostgreSQL instance handles ~5000 QPS; use sharding and replicas beyond that.
Start by clarifying notification types and delivery guarantees. Discuss user scale and traffic patterns. Identify bottlenecks step-by-step: database, queue, delivery. Propose incremental scaling solutions with clear reasoning. Mention trade-offs like latency vs cost and user experience.
Your database handles 1000 QPS. Traffic grows 10x. What do you do first?
Answer: Add read replicas to offload read queries and implement caching for frequent reads. For writes, consider sharding or batching writes to reduce load.
Practice
Solution
Step 1: Understand user preferences role
User preferences define how users want to receive notifications (email, SMS, push).Step 2: Identify responsible component
The User Management Service stores and manages user data including preferences.Final Answer:
User Management Service -> Option AQuick Check:
User preferences stored in User Management Service [OK]
- Confusing Notification Queue as storage for preferences
- Thinking Notification Delivery Service stores preferences
- Assuming Notification Generator manages user data
Solution
Step 1: Understand notification flow
Notifications are created, queued, then delivered.Step 2: Match correct order
Notification Generator creates, Notification Queue holds, Delivery Service sends.Final Answer:
Notification Generator -> Notification Queue -> Notification Delivery Service -> Option DQuick Check:
Creation, queue, delivery order = A [OK]
- Mixing delivery before queuing
- Starting with delivery service instead of generator
- Ignoring the queue component
Solution
Step 1: Analyze delivery service crash timing
Crash occurs after fetching from queue but before sending notification.Step 2: Understand queue behavior with acknowledgment
Without acknowledgment, message stays or returns to queue for retry.Final Answer:
Notification remains in the queue for retry -> Option CQuick Check:
Unacknowledged messages stay in queue [OK]
- Assuming notification is lost without retry
- Thinking notification is duplicated automatically
- Believing generator sends notification directly
Solution
Step 1: Identify bottleneck cause
Sequential processing limits throughput.Step 2: Apply partitioned queues with multiple instances
Partitioning allows parallel processing while preserving order per partition.Final Answer:
Add multiple delivery service instances with partitioned queues -> Option BQuick Check:
Parallelism with partitioning improves throughput [OK]
- Removing queue loses reliability and order
- Single-threaded service slows throughput
- Storing only in DB delays delivery
Solution
Step 1: Analyze scalability and latency needs
Millions of users and seconds-level delivery require scalable, decoupled design.Step 2: Choose microservices with separate components and horizontal scaling
This approach allows independent scaling, fault isolation, and faster processing.Final Answer:
Implement microservices with separate components for user preferences, notification generation, queuing, and delivery with horizontal scaling -> Option AQuick Check:
Microservices + scaling = scalable, fast delivery [OK]
- Using monolith limits scalability and speed
- Polling DB every minute causes delays
- Skipping queues reduces reliability
