Designing a notification system

The main requirements:

  • Push notification, SMS message, and email.
  • Soft real-time system.
  • Notifications can be triggered by client applications. They can also be scheduled on the server-side.
  • 10 million mobile push notifications, 1 million SMS messages, and 5 million emails.

Contact info gathering flow

To send notifications, we need to gather mobile device tokens, phone numbers, or email addresses. When a user installs our app or signs up for the first time, API servers collect user contact info and store it in the database.

image

Notification sending/receiving flow

image

Service 1 to N: A service can be a micro-service, a cron job, or a distributed system that triggers notification sending events. For example, a billing service sends emails to remind customers of their due payment or a shopping website tells customers that their packages will be delivered tomorrow via SMS messages.

Notification system: The notification system is the centerpiece of sending/receiving notifications. Starting with something simple, only one notification server is used. It provides APIs for services 1 to N, and builds notification payloads for third party services.

Third-party services: Third party services are responsible for delivering notifications to users. While integrating with third-party services, we need to pay extra attention to extensibility. Good extensibility means a flexible system that can easily plugging or unplugging of a third-party service. Another important consideration is that a third-party service might be unavailable in new markets or in the future. For instance, FCM is unavailable in China. Thus, alternative third-party services such as Jpush, PushY, etc are used there.

image

Events tracking

Notification metrics, such as open rate, click rate, and engagement are important in understanding customer behaviors. Analytics service implements events tracking. Integration between the notification system and the analytics service is usually required.

image

image

References

System design interviews

You Cannot Have Exactly-Once Delivery: bravenewgeek.com/you-cannot-have-exactly-on..

Security in Push Notifications: cloud.ibm.com/docs/services/mobilepush?topi..

RadditMQ: bit.ly/2sotIa6