Let’s discuss about how can we design a notification system also scale that to serve millions of users.
Functional Requirements
- Types of notifications our system will support — SMS, PushNotification, Email.
- Supported Devices — Mobile, Tablet, Desktop/Laptop.
- Who can use this system — Anyone registered as valid client.
High Level Design
We have different clients registered with our server i.e Notificaiton System. They send a notification request to our system and we have third party systems integrated to push the notifications via different modes. For IOS push notification we use APN, FCM is used for sending push notifications to android. For SMS we can use twillo, For email we can use any like send-grid, etc. Our system talks with third party to deliver the notifications.
This is very basic design, will work for small traffic. Let’s try to scale this system to serve millions of users.
Deep Dive
To scale our previous approach, we will use some caching mechanisms, messaging queues and a retry mechanism. For messaging queue we will use Kafka.
We have multiple clients sending requests to our notification system we have a caching system in place to cache some basic data like userinfo, templates, etc. Then we have different topics created for each type ie. sms, ios, android, email and we have worker nodes to handle once the message is processed by queue worker nodes take care of this and then notification service providers are integrated to send the notification.
Once the system receives any request for notification it checks for the type i.e sms, email, push-notification and then pushes to the respective kafka topic with producer. Once the consumers receives the event then it uses workers to sends the notification to third party services. In this way we can push as much notification requests it will be processed as per the queue.
Failure handle mechanisms.
Once any of the notification is failed to send it is pushed to back to the respective queue and tried again.
Hope you learned something new today with this….!!!