Design a notification system
Design a service that other teams call to notify users. It should support push, email and SMS, respect user preferences and quiet hours, never send the same thing twice, and keep working when a provider goes down.
About this problem
“Design a notification system” is a starter-level problem in the write-heavy / fan-out family. One action by one person creates work for thousands of other people.
The key challenge: Almost every notification has slack. This system's value is that it takes the work off other teams' request paths and spends that slack for them.
Time budgets: Urgent: seconds. Transactional: a minute. Marketing: hours.
The worked solution for Notification system goes through why those budgets shape the design, stage by stage.
Before you start
You will work this in five timed stages. Here is what each one asks you to think about. None of it is the answer; the answers unlock in the workspace below once you have written your own.
- Stage 1 · Requirements · 5 min
- Who calls this? One team or fifty? That changes the API and the abuse story.
- Is "we tried to send it" good enough, or must you prove delivery?
- What is the worst thing that happens if one notification is sent twice?
- Stage 2 · Actors and lifecycle · 6 min
- The provider is an actor you do not control. What does it do to you?
- What decisions does the platform make silently on the user's behalf?
- What happens to a notification that has been waiting three hours?
- Stage 3 · Numbers · 6 min
- Average is not the story here. What does a campaign look like?
- What is the peak-to-average ratio when marketing presses send?
- How much do you have to store, and for how long?
- Stage 4 · High-level design · 12 min
- What has to happen synchronously, and what must not?
- How do you stop the digest run from delaying a password reset?
- Where do preferences get checked — once, or per channel?
- Stage 5 · Deep dive and tradeoffs · 14 min
- What happens in the first minute of a provider outage?
- How do you send 20 million campaign messages without hurting anyone else?
- What stops a bug in a calling service from sending a user 5,000 emails?
Work it through
Five stages, gated. You write your answer for each stage before its model answer unlocks. That is the core of the method.
Done all five? The diagrams, numbers, trade-offs and follow-ups for this problem are on the worked solution page, to check your own design against.
How it is really built
Write your own answer first. Then read how teams who run this at scale describe it. Their constraints were real, and the write-ups often say what their choices cost.
- Avoiding insurmountable queue backlogs ↗What happens when the notification queue falls behind and never catches up.