Designbench

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

  1. Services send a request to one notification API: who, what, and how urgent.
  2. It checks the user’s preferences and quiet hours, and fills in the message template.
  3. It puts one message per channel on a queue.
  4. Channel workers send through the provider (Apple, Google, an SMS gateway, an email service), retrying with backoff when it fails.
  5. 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

Sections

  1. Requirements and numbers
  2. API and data
  3. Architecture
  4. Deep dive: reliable delivery
  5. Deep dive: restraint
  6. Design review

Cheat sheet

Pipelinequeue per channel + workers
Failuresjittered retries, then dead letters
Duplicatesnotification id + collapse key
Criticalown queue, bypasses quiet hours
Noiseprefs, quiet hours, limits, batching

The interactive simulations and the scored design review load with JavaScript.