Explore / Backend system design
Design a Notification System
Overview
Design the notification platform for a large consumer product. Other teams call it when something happens (an order shipped, a login code is needed, someone commented, a sale starts) and it reaches the user by push notification, email, SMS or the in-app inbox.
The question looks like "put a queue in front of some providers", and that answer earns a mid-level pass. The harder parts are what interviewers probe: a one-time login code must arrive in seconds while a marketing campaign to 50 million users is in flight, a retry must never send the same SMS twice, and the system must decide when not to send at all. Write your answer in the Write tab and sketch the pipeline in the Diagram tab.
Requirements
Functional
- Internal services send a notification to one user, a list of users or a saved segment.
- Channels: mobile push (APNs, FCM), email, SMS and an in-app inbox with an unread count.
- Templates with variables, localized per user.
- Users control what they get: per-category and per-channel opt-outs, quiet hours.
- Schedule a notification for later.
- Track status: accepted, sent, delivered, opened, failed.
Non-functional
- Latency by class: login codes and security alerts reach the provider within a few seconds. Marketing can take minutes.
- No lost notifications once the API has accepted them, and no visible duplicates.
- Isolation: a slow provider or a huge campaign must not delay other traffic.
- Scale: about a billion notifications a day, with campaign bursts far above the average.
- Respect for users and providers: frequency caps, unsubscribes honoured at once, provider rate limits obeyed.
Estimates
Assume 1 billion notifications a day: about 700 million push, 290 million email and 10 million SMS. Assume peaks of 5× the average and a marketing campaign that must reach 50 million users within 30 minutes. Work out:
- Average and peak sends per second, and what the campaign adds.
- How many sender workers you need if one provider call takes about 100 ms.
- Storage for the delivery log and the in-app inbox.
- Memory for de-duplication keys kept for 24 hours.
Hints
- The caller should not wait for Apple, Google or a mail server. What does the API do before it returns?
- Should a login code and a "20% off shoes" push share a queue?
- Workers crash between "called the provider" and "recorded the result". What happens on retry?
- A provider answers
429 Too Many Requests. Another answers "this device token no longer exists". Should both be retried? - Where in the pipeline do you check the user's preferences, and what if they change while a message is queued?
Follow-ups
- The SMS provider is down for 20 minutes. What happens to login codes?
- A user gets 40 likes in a minute. How many pushes do they receive?
- How do you send a campaign at 9 am local time in every time zone?
- How would you prove to a support agent what happened to one specific notification?
- A buggy caller sends the same event 10 million times. What protects users?
Write your answer step by step and compare it with the reference solution on GrindPrep.