Example: Notification system

Three types of notification formats are: mobile push notification, SMS message, and Email.

Step 1 - Understand the problem and establish design scope

Candidate: What types of notifications does the system support? Interviewer: Push notification, SMS message, and email.

Candidate: Is it a real-time system? Interviewer: Let us say it is a soft real-time system. We want a user to receive notifications as soon as possible. However, if the system is under a high workload, a slight delay is acceptable.

Candidate: What are the supported devices? Interviewer: iOS devices, android devices, and laptop/desktop.

Candidate: What triggers notifications? Interviewer: Notifications can be triggered by client applications. They can also be scheduled on the server-side.

Candidate: Will users be able to opt-out? Interviewer: Yes, users who choose to opt-out will no longer receive notifications.

Candidate: How many notifications are sent out each day? Interviewer: 10 million mobile push notifications, 1 million SMS messages, and 5 million emails.

Step 2 - Propose high-level design and get buy-in

• Different types of notifications • Contact info gathering flow • Notification sending/receiving flow

Different types of notifications

  1. Android/Iphone
  2. image
  3. SMS
  4. image
  5. Email
  6. image
    image

Contact info gathering flow

image
image

Notification sending/receiving flow

image
image
image

Notification servers: They provide the following functionalities: • Provide APIs for services to send notifications. Those APIs are only accessible internally or by verified clients to prevent spams. • Carry out basic validations to verify emails, phone numbers, etc. • Query the database or cache to fetch data needed to render a notification. • Put notification data to message queues for parallel processing.

Cache: User info, device info, notification templates are cached. DB: It stores data about user, notification, settings, etc. Message queues: They remove dependencies between components. Message queues serve as buffers when high volumes of notifications are to be sent out. Each notification type is assigned with a distinct message queue so an outage in one third-party service will not affect other notification types. Workers: Workers are a list of servers that pull notification events from message queues and send them to the corresponding third-party services.

Step 3

How to handle the errors?

image

Also other considerations:

image
image
image
image
image
image

Step 4

Latest design

image
image
SuperMade with Super