![]() |
If we are building an e-commerce application or a booking system or anything of that sort, we will always have a notification service that will be used to notify your consumers. Let us now look at the requirements to build a notification service. Topics for Designing Notification ServicesRequirementsThere are some functional (FRs) and non-functional requirements (NFRs) that this platform should support. Functional Requirements:
Example:
Prioritization: Some messages have low priority while other messages are of high priority. If we are sending a one-time password (OTP), then that’s a very high-priority message. But if it’s a promotional message, it is okay if it’s low priority, and if it gets delayed Non-Functional Requirements:
The diagram of architecture is as follows: ComponentsThe starting point of the whole system is a couple of clients i.e. Client 1, Client 2. There are 2-3 kinds of requests that they can send us. But all of those requests would come under a category called Notification service, which is an interface that allows us to talk to the other teams in the company, other companies, etc. There are two kinds of requests mainly:
The idea of the notification service is that it will take the request, put it into Kafka, and respond to the client. We could make this transaction as a synchronous flow but that will take a bit more time and that will keep the client blocked. But if for a very critical scenario, we need it to be a synchronous flow, we can make the whole process synchronous through API calls. Notification Validator and Prioritizer
The main thing that it does is it decides the priority for a message. Based on some attribute within the message. After deciding the priority, it puts the event into a Kafka topic, specific for each priority. The idea is – we don’t want any time lag in the high-priority messages, but at times, it would be okay if there’s a spike in low-priority messages and hence it takes time. Rate Limiter and Notification Handler & User Preferences
Rate Limiter does two kinds of rate limiting:
The next component is something called Notification Handler and User Preferences. The user might prefer receiving emails over SMS or the user may want to unsubscribe from all the promotional messages. So all of these duties would be handled by this User Preference Service. It has two components that it talks to:
Note: We will have a complete mechanism that we may use to notify once everything has been resolved Email HandlerIt is responsible for gathering and then transferring all email requests by calling the email vendor, which will send out the real emails. The email vendor could be a simple SMTP server that you have at our end. In-App HandlerIt handles all the in-app notifications that we want to send out or push notifications. We can use a Firebase for Android and use Apple push notification service for sending out such notifications on the iOS platform. IVRS HandlerWe can have an IVRS Handler. A classic example would be Amazon or Flipkart. When we place a very high-value cash on-delivery (CoD) order, they send us an IVRS call, to ensure that we have really made that transaction and ask for our confirmation. So all of those things could be handled by the IVRS Handler. This is a very rare scenario and it would happen once in a while when compared to SMS or emails. Notification TrackerWe always need to keep track of all notifications we have sent. In case somebody later makes false claims there is some proof required, we need to know what communication we have sent out. So for all of that, we have a Notification Tracker which puts all the notifications that we have sent out on its own Cassandra. How does our system tackle if we want to send bulk notifications?Let’s say for all the users who have ordered a TV in the last 24 hours, we have to send them a notification for installation service, these things are a part of something called as bulk notification. So the very first requirement for this would be a UI, which is represented as Bulk Notification UI (in the architecture above), which will talk to something called as Bulk Notification service, which takes a filter criteria. Filter criteria would be something like finding all the users who have placed a milk order in the last three days and sending them a notification. Query EngineOn top of this data store, there’s something called as Query Engine. That Query Engine basically takes a query, which is like an aggregator plus filter kind of thing, and can be used to find out all the users who are in Bangalore, or who have ordered some food item in the last few days. This Query Engine is not only used by the Notification service, it could be used by a lot of services. SchedulerA scheduler is a component that manages the timing and scheduling of tasks or events. In the context of a notification service, the scheduler determines when to send notifications based on user preferences, timing settings, and priorities. PipelinesPipelines are a series of steps or stages through which data or tasks flow. In a notification service, pipelines can be used to process and transform notifications before dispatching them to different channels. For example, a pipeline might include steps to format the notification content, add personalization, or apply language localization. Batch JobsBatch jobs are recurring tasks or processes that are executed in batches, typically with a predefined frequency or schedule. In a notification service, batch jobs can be used to perform periodic tasks such as generating aggregated reports, updating user preferences, or cleaning up old notifications. Use case for Notification ServiceA common use case for a notification service is in an e-commerce platform. The system can send various types of notifications to users, including order confirmations, shipment updates, promotional offers, and abandoned cart reminders. Users can manage their notification preferences, such as choosing to receive notifications via email, SMS, or push notifications. The notification service ensures timely delivery of notifications based on user preferences and tracks user engagement metrics to improve the effectiveness of notifications. |
Reffered: https://www.geeksforgeeks.org
System Design |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |