A notification alerts a user with important info like events, … It’s more than just mobile push notifications.
There are 3 types of notification formats are : mobile push notification, SMS message and Email.
Step 1 - Understand the problem and establish the scope
Types of notifications to support ?
Push notifications, SMS Message and Email
Real-time System ?
Real-time, but a delay is acceptable.
Supported devices ?
iOS devices, android devices and laptop/desktop.
Triggers ?
Triggered by client app and scheduled on the server-side.
Users be able to opt-out ?
Chose to opt-out means no longer receive notifications.
How many notifications per day ?
10 million for Mobile push notif., 1 million for SMS, 5 millions for emails.
Step 2 - High-level design
No need to propose a high-level design with a single server setup because of the following reasons :
One single notification server, so a single point of failure.
Challenging to scale (limitations).
Processing and sending notifications could be resource intensive.
Step 3 - Design deep dive
Reliability
Purpose is to show additional components : notification template, rate limiting, retry mechanism… One of the most requirements is to prevent data loss with a retry mechanism and notification log.
The notification servers are equipped with 2 features : authentication and rate-limiting.
A retry mechanism to handle notification failure : retry for a predefined number of times.
Worker will process from a notification template to be more efficient.
To prevent data loss, data will be stored as log.
Step 4 - Pros & Cons
Pros
Retry mechanism to minimize the failure rate;
User Info DB used as User Setting to help user to opt-out of receiving notifications;
Rate limiting helping to control the frequency.
Cons
Multiple queue (for each provider) to maintain and to manage.