What if you could tell millions about your news in seconds, without lifting a finger?
Why Notification system design in HLD? - Purpose & Use Cases
Start learning this pattern below
Jump into concepts and practice - no test required
Imagine you run a small online store and want to tell your customers about new deals. You try sending emails or messages one by one, copying and pasting each time.
It feels like shouting in a noisy room, hoping the right people hear you.
Sending notifications manually is slow and tiring. You might forget someone or send duplicates. It's hard to keep track of who got what.
As your store grows, this manual way becomes a big headache and wastes your time.
A notification system automates sending messages to many users at once. It organizes who should get what and when, without mistakes.
This system can send emails, texts, or app alerts quickly and reliably, saving you effort and making customers happy.
for user in users: send_email(user.email, message)
notification_service.send_bulk(users, message)
With a notification system, you can reach thousands of users instantly and keep them engaged without lifting a finger.
Social media apps use notification systems to alert you about likes, comments, or messages in real time, keeping you connected and informed.
Manual notifications are slow and error-prone.
Notification systems automate and scale message delivery.
This improves user engagement and saves time.
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
