Lesson 6.5 · 25 min
Notification system
Send 10,000 notifications through a provider outage and an SMS cap until none are lost or doubled, then tame one user's noisy day from 70 buzzes to 5 without missing the 3 AM security alert.
The idea in plain words
A notification system is the one messenger every other part of the product uses to reach people by push, text or email. It must not lose important messages, not send them twice, and not wake anyone at 3 AM for something trivial.
The problem it solves
Many parts of a product need to tell users things, through push, SMS and email providers that are each unreliable in their own way, without losing important alerts or spamming people.
How it works
- Services send a request to one notification API: who, what, and how urgent.
- It checks the user’s preferences and quiet hours, and fills in the message template.
- It puts one message per channel on a queue.
- Channel workers send through the provider (Apple, Google, an SMS gateway, an email service), retrying with backoff when it fails.
- A notification id is used to avoid sending the same alert twice.
Example
A one-time sign-in code must arrive in seconds, so it skips quiet hours and jumps the queue. A “new follower” alert at 3 AM waits until morning and may be bundled with others into one message.
Key terms
- Channel
- How a message is delivered: push, SMS or email.
- APNs / FCM
- Apple’s and Google’s services that deliver push notifications to phones.
- Template
- A message layout with blanks filled in per user.
- Deduplication
- Recognizing a repeat of the same notification and sending it only once.
- Quiet hours
- Times a user doesn’t want non-urgent notifications.
In this lesson you'll learn
- How to size push, SMS and email traffic and a broadcast to millions.
- How per-channel queues, backoff retries, dedup and dead letters keep notifications from being lost or doubled.
- How urgency tiers, quiet hours, rate limits and batching keep notifications useful, and how to defend the design.
Sections
- Requirements and numbers
- API and data
- Architecture
- Deep dive: reliable delivery
- Deep dive: restraint
- Design review
Cheat sheet
| Pipeline | queue per channel + workers |
|---|---|
| Failures | jittered retries, then dead letters |
| Duplicates | notification id + collapse key |
| Critical | own queue, bypasses quiet hours |
| Noise | prefs, quiet hours, limits, batching |
The interactive simulations and the scored design review load with JavaScript.