What if you could reach millions of users instantly without lifting a finger?
Why Notification system in LLD? - 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 when their orders ship. You try sending emails one by one manually every time an order is ready.
Sending notifications manually is slow and tiring. You might forget some customers or send duplicate messages. As orders grow, it becomes impossible to keep up without mistakes.
A notification system automates sending messages to users. It handles many notifications at once, keeps track of delivery, and retries if needed. This saves time and avoids errors.
for order in orders: send_email(order.customer_email, 'Your order shipped!')
notification_service.send_bulk('order_shipped', orders)It makes real-time, reliable communication with users possible at any scale, improving user experience and trust.
Social media platforms use notification systems to instantly alert you about likes, comments, or messages without delay or missing any updates.
Manual notifications are slow and error-prone.
Notification systems automate and scale message delivery.
This leads to timely, reliable user communication.
Practice
Solution
Step 1: Understand the role of event producers
Event producers create or detect events that require notifying users, such as a new message or alert.Step 2: Differentiate from other components
Notification service processes events, delivery channels send notifications, and user preferences store user settings.Final Answer:
Event Producer -> Option DQuick Check:
Event source = Event Producer [OK]
- Confusing notification service with event producer
- Thinking delivery channel generates events
- Assuming user preferences create events
Solution
Step 1: Identify the logical flow of notification
First, an event is generated by the event producer, then processed by the notification service, and finally sent via the delivery channel.Step 2: Eliminate incorrect sequences
Delivery channel cannot start the process; user preferences store is not part of the sending sequence.Final Answer:
Event Producer -> Notification Service -> Delivery Channel -> Option BQuick Check:
Event -> Process -> Send = A [OK]
- Reversing the order of components
- Including user preferences in the sending chain
- Confusing delivery channel as event source
Solution
Step 1: Understand user preference handling
If a user selects multiple delivery channels, the system should send notifications through all preferred channels to ensure delivery.Step 2: Confirm expected multi-channel delivery
Sending via both email and SMS respects user choice and increases notification reach.Final Answer:
Send notification via both email and SMS -> Option AQuick Check:
Multiple preferences = multiple channels [OK]
- Sending notification on only one channel
- Ignoring user preferences
- Not sending notification at all
Solution
Step 1: Analyze queue role in notification system
Queue buffers events to handle load. If overloaded, it causes delays in processing notifications.Step 2: Evaluate other options
Missing user preferences or instant delivery does not cause delay; too few events would reduce load, not increase delay.Final Answer:
Queue is overloaded with too many events -> Option AQuick Check:
Queue overload = delay [OK]
- Blaming delivery channel for delays
- Assuming missing preferences cause delay
- Thinking fewer events cause delays
Solution
Step 1: Consider scalability requirements
Millions of users require distributed services and sharded queues to handle load without bottlenecks.Step 2: Address user customization needs
Dynamic delivery channel selection per user allows personalized notifications respecting preferences.Step 3: Evaluate other options
Centralized service and single queue create bottlenecks; synchronous sending blocks processing; local files do not scale or support dynamic preferences.Final Answer:
Implement distributed notification services with sharded queues and dynamic delivery channel selection per user -> Option CQuick Check:
Distributed + dynamic preferences = scalable & customizable [OK]
- Choosing centralized design causing bottlenecks
- Using synchronous sending blocking system
- Storing preferences in non-scalable local files
