Design a Notification Service
Understanding the Problem
🔔 What is a notification service? A notification service is the shared platform every other team calls when they need to tell a user something: "your order shipped," "here's your login code," "Alex mentioned you." It takes one request, decides whether and how the user should hear about it, renders the message for each channel (push, email, SMS, in-app), and hands it to the right delivery provider. Product teams get one API instead of each integrating with Apple, Google, an email provider and an SMS provider themselves.
Several requests fold into this one. "Design an APNs-like push system" asks you to build the delivery layer that a notification service normally calls, so we'll cover it as a deep dive. "Design PagerDuty-style escalation" is a notification service where a message must be acknowledged, and if it isn't, the system tries the next channel or the next person. That's a deep dive too. Preferences and filtering are core requirements.
Functional Requirements
Ask who the callers are. Here they're internal services, not end users, which shapes the API: callers send events about users, and the platform decides what the user actually sees.
Core Requirements
- Internal services should be able to send a notification to a user (or a list of users) over push, email, SMS and in-app.
- Users should be able to set preferences: which categories they want, on which channels, and quiet hours.
- The system should filter notifications: drop duplicates, cap how many a user gets, hold non-urgent ones during quiet hours.
- Urgent alerts should escalate: if not acknowledged within a time limit, try another channel or another person.
Below the line (out of scope)
- Building the template editor and campaign tooling for marketing.
- Analytics dashboards on open and click rates (we'll emit the events, not build the dashboards).
- Rich in-app inbox UI.
Non-Functional Requirements
Get numbers from your interviewer. We'll assume a consumer app with 500 million users, sending 2 billion notifications a day across channels, with marketing campaigns that can target 100 million users at once.
Core Requirements
- Transactional notifications (login codes, security alerts, pages) should reach the provider within a few seconds, p99.
- The system must not lose a notification once accepted, and should not send duplicates.
- The system should absorb bursts: a campaign to 100M users must not delay login codes.
- It should respect each provider's rate limits and keep working when one provider is down.
- Preference checks must be correct: a user who unsubscribed must never get that category again.
Below the line (out of scope)
- Guaranteed delivery to the device. Once Apple, Google, or the carrier has the message, it's out of our hands.
- Strong ordering between notifications for the same user.
Back-of-the-envelope: 2B per day ÷ 86,400 ≈ 23k notifications per second on average. Campaigns make it spiky: sending 100M in one hour is ~28k/s on top of the baseline, and teams will want it faster. Plan for a peak around 100k/s. Each notification is small (a few hundred bytes of request, a couple of KB rendered for email), so bandwidth isn't the issue. The issues are per-provider throughput limits, preference lookups at 100k/s, and priority: one in a thousand of those messages is a login code someone is staring at their phone waiting for.
The key insight is that notifications are not one workload. A login code and a "we miss you" email have completely different latency needs, and if they share one queue, the campaign wins by sheer volume. Separate them by priority early in the design.