What it is
A notification platform takes requests such as "tell user 42 that order 981 has shipped" from many internal services and delivers them over push, email and SMS through external providers. It decides which channels to use for each user, renders the message, sends it, retries failures and records what happened.
This lesson builds the delivery pipeline in the 3D scene and runs its hard parts in the simulation: decoupling, per-channel fan-out, a provider outage, retries and dead letters, and a campaign flood. The full interview version, with API, data model, deduplication and capacity estimates, is at /system-design/interviews/notification-service. The building blocks are covered in Message Queues, Publish/Subscribe and Dead Letter Queues.
Why it exists
Every product team needs notifications, and each one built separately duplicates provider integrations, preference handling, retries and compliance (unsubscribe links, quiet hours). A shared platform does it once. Its hard requirements come from the mix: login codes must arrive within seconds, campaigns produce bursts tens of times the average, and providers are slow, rate limited and sometimes down.
How it works
Estimates. The interview assumes about 200 million deliveries a day:
| Quantity | Arithmetic | Result |
|---|---|---|
| Average | 200M ÷ 86,400 s | ≈ 2,300 /s |
| One campaign | 50M users ÷ 3,600 s | ≈ 14,000 /s |
| SMS average | 10M ÷ 86,400 s | ≈ 115 /s (provider contract e.g. 1,000 /s) |
The design is driven by bursts and provider limits, not the average.
Accept, then deliver. The API authenticates the calling service, checks the idempotency key, stores the notification and answers 202 Accepted. It never calls a provider. In the simulation's first step, a synchronous design collapses when the email provider slows eight times: the API's workers all wait on it.
Route and fan out. A router consumes accepted notifications, loads the user's preferences (cached), the category's channel policy, devices and suppressions, and decides channels and timing. Quiet hours or a future send_after go to a delay queue or scheduler. For each (channel, address) it writes a delivery record and publishes a message onto a per-channel, per-priority queue: push.transactional, email.bulk, and so on.
Send. Each queue has its own sender pool. A sender claims the delivery, renders the template, takes a token from the provider's rate limiter, calls the provider and records the result. Provider callbacks (delivered, bounced, invalid token) update status and suppressions.
Isolation. Because SMS has its own queue and senders, an SMS provider outage fills only the SMS queue. In the simulation, push and email keep delivering about 40 messages per second each while SMS stalls. With one shared pool, failing SMS sends would hold workers that email needs. Where a second provider exists for a channel, senders fail over to it.
Retries, backoff and dead letters. Transient failures are retried with exponential backoff and jitter, for a bounded number of attempts; then the message goes to a dead letter queue. The DLQ is alerted on and replayed after the incident, skipping messages that have expired (a login code is useless after a few minutes). Permanent failures (invalid number, hard bounce) are not retried but recorded as suppressions.
Priority and pacing. A campaign must never delay a login code. Transactional and bulk traffic get separate queues and sender pools, and the campaign fan-out job publishes at a configured rate that the provider contract allows. In the simulation, a campaign on the shared email queue grows it by more than a hundred messages a second; on its own paced queue, the transactional queue stays empty.
Delivery semantics. Queues deliver at least once: a sender that crashes after the provider accepted a message but before acknowledging it will send it again. Senders deduplicate with an idempotency key per delivery (for example a conditional status update or a dedup store with a 24-hour TTL), so a retry rarely becomes a second message.
When to use it
When several teams send notifications, when more than one channel is involved, or when volume and provider limits require queuing and pacing. A single service sending a few emails can call a provider SDK through its own queue without a platform.
When not to
- Very low volume, one channel: a background job with a retry is enough.
- Real-time in-app updates to connected clients belong on a WebSocket or SSE channel, not a store-and-forward pipeline (the platform can feed it, though).
- Messages that must be delivered exactly once in a legal sense (payment confirmations of record) still need a durable record in the owning system; a notification is a courtesy copy.
Trade-offs
| Choice | You gain | You pay |
|---|---|---|
| Accept-then-queue (202) | Callers isolated from providers; bursts absorbed | Delivery is asynchronous; status must be queried or called back |
| Per-channel, per-priority queues | Outages and campaigns contained | More queues, pools and dashboards |
| At-least-once with idempotency keys | No lost messages | Dedup store and conditional updates on the hot path |
| Retries with backoff and a limit | Rides out transient failures without hammering providers | Delivery can be minutes late during incidents |
| Pacing campaigns | Stays within provider contracts; protects reputation | Campaigns take longer |
| Second provider per channel | Survives a provider outage | Two integrations, templates and cost models to maintain |
Alternatives
- Managed notification services (cloud push/email/SMS services) instead of direct provider integrations: less to run, less control over routing and failover.
- A log-based backbone (partitioned event stream) instead of queues for the ingest stage: replayable and ordered per user, but per-message retry and delay are harder.
- Per-team integrations: no shared platform, maximum autonomy, duplicated effort and inconsistent user experience.
Failure modes
- Provider outage (simulated): the channel's queue grows. Contain it per channel, retry with backoff, fail over to a second provider where possible, and expire messages that are no longer useful.
- Retry storm: immediate, unbounded retries consume all sender capacity and hit the provider when it recovers. In the simulation, each failed attempt holding a sender for a full lease cut SMS throughput to 16 attempts per second.
- Campaign flood (simulated): bulk traffic in a shared FIFO queue delays urgent messages.
- Duplicates: a crash between provider acceptance and ack resends; idempotency keys prevent most visible duplicates.
- Silent DLQ growth: dead letters nobody watches are lost notifications. Alert on DLQ depth and age.
- Preference bugs: sending to users who opted out is a legal and trust problem. Treat preference checks as part of the critical path and test them.
In production
Monitor queue depth and the age of the oldest message per queue (age is what users feel), send success rate per provider, DLQ depth, and end-to-end time from accept to provider acceptance for transactional traffic. Autoscale senders on queue age, within provider limits. Keep templates versioned and owned by the calling teams. Honour unsubscribe and quiet hours in the router, not in the senders. Rate-limit callers per service so one team cannot flood the platform (Rate Limiter).
Common misconceptions
- "A queue makes delivery reliable on its own." Only with acks, bounded retries, a watched DLQ and idempotent senders.
- "Retrying faster recovers faster." Fast unbounded retries burn capacity and can extend a provider outage.
- "One big queue with many workers is simplest." It is, until an SMS outage or a campaign stalls everything behind it.
- "Exactly-once delivery is achievable." Across an external provider, at-least-once plus deduplication is the realistic guarantee.
Interview angle
Estimate average and campaign rates, then draw: API (202 + idempotency), router with preferences, per-channel and per-priority queues, sender pools with provider rate limiters, callbacks and status. Expect follow-ups on provider outages and failover, retries and DLQs, campaigns delaying login codes, deduplication, quiet hours across time zones, and how you would add a new channel. Work the full problem at /system-design/interviews/notification-service.
Model assumptions
The simulation is a simplified model, not a benchmark. Product services send 40 notifications per second (Poisson). The router is a topic that copies every notification to all three channels; per-user preference filtering is a scripted illustration. Push and email senders have 8 workers (about 50 ms and 100 ms per send), SMS senders 16 workers (about 50 ms), bulk email senders 8 workers (about 100 ms); service times are lognormal. Providers are scenery: an outage is modelled as the sender failing every send. A failed send is not acknowledged; the message stays leased until the queue's visibility timeout (1 s, then 120 ms from the backoff step on) and is delivered again, with a fixed delay. Exponential backoff is not modelled by the engine and is shown as a scripted walk-through for one message. The dead letter queue takes messages after 3 deliveries; replay is described, not simulated. In the first step the email provider is simulated as a server (32 workers, ~150 ms) that slows eight times. Numbers show behaviour and orders of magnitude only.