This system sends notifications to all relevant parties efficiently and reliably. It supports multiple notification channels like email, SMS, and push notifications, ensuring messages reach users promptly.
Notification to all parties in LLD - Architecture Diagram
Start learning this pattern below
Jump into concepts and practice - no test required
or
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
System Overview - Notification to all parties
Architecture Diagram
User | v Load Balancer | v API Gateway | v Notification Service | | | v v v Email Service SMS Service Push Service | | | v v v Email Server SMS Gateway Push Server | v Database | v Cache
Components
User
client
Initiates notification requests
Load Balancer
load_balancer
Distributes incoming requests evenly to API Gateway instances
API Gateway
api_gateway
Routes requests to Notification Service and handles authentication
Notification Service
service
Processes notification requests and sends to appropriate channel services
Email Service
service
Formats and sends email notifications
SMS Service
service
Formats and sends SMS notifications
Push Service
service
Formats and sends push notifications
Email Server
external_service
Delivers emails to recipients
SMS Gateway
external_service
Delivers SMS messages to recipients
Push Server
external_service
Delivers push notifications to devices
Database
database
Stores user contact info and notification logs
Cache
cache
Stores frequently accessed user data for faster retrieval
Request Flow - 17 Hops
User → Load Balancer
Load Balancer → API Gateway
API Gateway → Notification Service
Notification Service → Cache
Cache → Notification Service
Notification Service → Database
Database → Notification Service
Notification Service → Email Service
Notification Service → SMS Service
Notification Service → Push Service
Email Service → Email Server
SMS Service → SMS Gateway
Push Service → Push Server
Notification Service → Database
Notification Service → API Gateway
API Gateway → Load Balancer
Load Balancer → User
Failure Scenario
Component Fails:Database
Impact:Notification service cannot retrieve or log user info; notifications may be delayed or incomplete
Mitigation:Use cache for reads to serve recent user info; queue logs for later retry; implement database replication for high availability
Architecture Quiz - 3 Questions
Test your understanding
Which component is responsible for distributing incoming user requests evenly?
Design Principle
Practice
1.
What is the main purpose of a notification system that sends messages to all parties?
easy
Solution
Step 1: Understand the role of notifications
Notifications are designed to deliver messages to users or parties quickly and efficiently.Step 2: Identify the main goal
The main goal is to share important information with all involved parties without delay.Final Answer:
To quickly share important messages with everyone involved -> Option AQuick Check:
Notification purpose = quick message sharing [OK]
Hint: Notifications = fast message delivery to all involved [OK]
Common Mistakes:
- Confusing notifications with data storage
- Thinking notifications perform data processing
- Assuming notifications create user profiles
2.
Which of the following is the correct way to represent a notification service that sends messages to all parties in pseudocode?
function notifyAll(parties, message) {
for (let i = 0; i < parties.length; i++) {
parties[i].send(message);
}
}easy
Solution
Step 1: Analyze the pseudocode loop
The code loops through each party in the parties list using a for loop.Step 2: Check the send method call
Inside the loop, it calls send(message) on each party, ensuring all get notified.Final Answer:
Loop through parties and call send(message) on each -> Option CQuick Check:
Loop + send call = notify all [OK]
Hint: Loop through all parties to send message [OK]
Common Mistakes:
- Sending message only once
- Not looping through all parties
- Calling send outside the loop
3.
Consider this code snippet for notifying parties:
parties = ["Alice", "Bob", "Charlie"]
function notifyAll(parties, message) {
let notified = []
for (const person of parties) {
notified.push(person + ": " + message)
}
return notified
}
console.log(notifyAll(parties, "Meeting at 5 PM"))What will be the output?
medium
Solution
Step 1: Understand the loop behavior
The function loops over each person in parties and creates a string combining their name and the message.Step 2: Check the returned list
The notified list contains strings like "Alice: Meeting at 5 PM" for each party.Final Answer:
["Alice: Meeting at 5 PM", "Bob: Meeting at 5 PM", "Charlie: Meeting at 5 PM"] -> Option AQuick Check:
Loop + string concat = list of personalized messages [OK]
Hint: Each party gets message with their name prefixed [OK]
Common Mistakes:
- Returning only messages without names
- Returning original party list
- Assuming function is undefined
4.
Identify the bug in this notification function and select the fix:
function notifyAll(parties, message) {
for (let i = 0; i < parties.length; i++) {
parties.send(message)
}
}medium
Solution
Step 1: Identify incorrect method call
The code calls send on the entire parties array instead of individual party objects.Step 2: Fix by indexing the array
Use parties[i].send(message) to call send on each party in the loop.Final Answer:
Changeparties.send(message)toparties[i].send(message)-> Option DQuick Check:
Call send on each party object [OK]
Hint: Call send on parties[i], not parties array [OK]
Common Mistakes:
- Calling send on the whole array
- Using wrong loop condition
- Adding unnecessary return inside loop
5.
You are designing a notification system to alert all parties involved in a project. Which design choice best ensures scalability and reliability?
- A. Use a single server to send notifications sequentially to all parties.
- B. Send notifications only to a random subset of parties to reduce load.
- C. Store all notifications in a database and send them manually when needed.
- D. Use a message queue to distribute notification tasks to multiple worker servers.
hard
Solution
Step 1: Evaluate single server approach
Sending sequentially from one server limits scalability and can cause delays or failures.Step 2: Consider message queue with workers
Using a message queue allows distributing notification tasks to multiple workers, improving scalability and reliability.Step 3: Assess other options
Storing notifications for manual sending is slow; sending to random subset misses parties.Final Answer:
Message queue with multiple workers -> Option BQuick Check:
Queue + workers = scalable, reliable notifications [OK]
Hint: Use queues and workers for scalable notifications [OK]
Common Mistakes:
- Relying on single server for all notifications
- Sending notifications manually
- Skipping parties to reduce load
