# Push notifications - the token outlives the install

> Why push failures are silent, and how token lifecycle keeps a dead token from counting as delivered. Delivery is measured at the provider's door, not at the…

Source: https://tierslate.com/templates/push-notifications

Messaging & realtime · System design · core · 8 step walkthrough · 5 tables

Why push failures are silent, and how token lifecycle keeps a dead token from counting as delivered.

**Own this board: 400 credits.** The first act plays on the page. Owned once with credits, never a subscription.

## What this board gets wrong on purpose

The tension: Delivery is measured at the provider's door, not at the phone. A send to a token belonging to a deleted app returns 200 and is counted as delivered, so a cohort can go completely dark while the dashboard stays at 99.9% - and nothing on the board can tell "delivered" from "accepted by a cloud that will drop it". The only correction is the feedback band, which is asynchronous, lossy, differently shaped per provider, and by far the least-exercised code here. It is also the most dangerous: the reaper retires tokens on a signal nobody verifies, so one mis-parsed 410 permanently un-notifies a real user with no error anywhere. And the batcher, which exists so a 25M broadcast does not open 25M connections, delays every transactional notification behind whatever marketing is sending.

## Practise this as an interview

Take Push notifications - the token outlives the install as a timed system design interview on a blank board - on your own, with the requirements to check yourself against, or with a candidate you invite.

## Start here

### Why this design

Push looks like "call Apple, call Google" and is really a lesson in systems whose failures are silent. A send that fails is retried and nobody notices; a send to a dead token returns 200 and is counted as delivered. Interviewers use it to see whether you design the return path - token lifecycle, provider feedback, idempotency - and whether you can separate a 25M-user marketing broadcast from the one-time passcode that must arrive in seconds. Real notification teams are judged on exactly those two things.

### What you will learn

- How one notification becomes 2.4 device sends, and why 400M notifications a day is 960M send attempts and a send log - not the notification - is what you size for.
- Why the real peak is a step, not a curve: a broadcast to 25M users in ten minutes is 100,000 sends a second, nine times the daily peak, and autoscaling cannot catch a step.
- Why transactional and marketing traffic need separate lanes, and what a batcher costs the message that is queued behind a campaign.
- How to read provider responses correctly: a 429 means slow down and retry, a 410 means the token is dead and must be retired - and retiring a live token by mistake silently un-notifies a real person.
- Why the feedback band is the only thing keeping 34,000 dead tokens a day out of the registry, and why "delivered" on a dashboard means "accepted by the provider".

### How to read this board

1. Press Play and follow the walkthrough along the top: DECIDE (who, which devices, may we), then SEND (the conveyor belt), then NOT OURS (APNs and FCM) and THE PHONE.
2. Then read the FEEDBACK band underneath it right to left - that is the direction the truth travels, hours later.
3. 1 · Requirements - the questions that separate a passcode from a promotion.
4. 2 · Capacity estimation and 3 · Storage estimation - the 2.4x device fan-out, the broadcast step and why the send log is the big table.
5. 4 · Availability - what "delivered" can and cannot mean when the last hop is somebody else's cloud.
6. 5 · How it works, then 6 · Deployment plan.
7. Finally the DATA MODEL below the band, and then the conversation this board leaves open on purpose: the reaper retires tokens on a signal nobody verifies.

## 1 · Requirements

### Ask these before drawing anything

- Are these notifications transactional, marketing, or both? If both, they must not share a queue, and the reason is on the capacity page.
- What is the latency promise? "A 2FA code within 5 seconds" and "a digest sometime this evening" are two systems, and batching is fatal to the first.
- Do we need to know whether a notification was SEEN, or only that it was accepted? Seen requires client telemetry and changes the data model.
- How do we define a dead token, and how long may a token stay dead before we notice? This is the number the whole board is built around.
- Can the payload contain personal data? If yes it crosses a third-party cloud, which is a compliance question before it is an engineering one.
- Is there a per-user rate limit or a daily cap? Without one, every team with API access can burn the notification channel for everyone else.
- Web push and email fallback: are they in the same system? Sharing preferences across channels is easy; sharing delivery is not.
- What happens when the provider is down for an hour - do we drop, delay, or deliver late? A stale notification can be worse than none.

### Functional

- Accept a send for a user and deliver it to every eligible device they own.
- Respect per-category preferences, quiet hours and mutes; suppress when the user has already seen the thing on another surface.
- Collapse repeated notifications for the same subject into one (collapse keys).
- Retry transient provider failures with backoff; never retry a permanent one.
- Detect and retire dead tokens, and stop sending to them.
- Register, rotate and de-duplicate device tokens.
- Report, per notification, what happened as far as we can honestly know.

### Non-functional

- Transactional: p95 from accept to handed-to-provider under 2 seconds.
- Marketing: a 25M-user broadcast fully handed over within 30 minutes.
- 99.9% availability for accepting a send. Delivery itself is explicitly not ours to promise, and the SLA says so.
- At-most-once per collapse key per window; duplicates are worse than lateness here, because a duplicate is visible on a lock screen.
- Dead tokens retired within 24 hours of the provider telling us.

### Out of scope

- Composing the copy, localisation, and A/B assignment - upstream of the API.
- In-app inbox and web push.
- Deciding WHETHER something is worth notifying about, which is a product problem that no amount of infrastructure fixes.

## The rest of this board

This page publishes the question. The answer - 5 more written pages, an 8-step narrated walkthrough and a 5-table schema - is the board itself, and it opens in Tierslate.

- 5 written pages
- 8 walkthrough steps
- 5 tables (39 columns)

5 pages behind this one:

- Capacity estimation
- Storage estimation
- Availability
- How it works
- Deployment plan

## Related system design templates

- [Chat and messaging system design](https://tierslate.com/templates/chat-messaging) - Delivery guarantees, presence and ordering across devices.
- [Transactional email system design](https://tierslate.com/templates/email-delivery) - Why getting an email into the inbox is a negotiation with a receiver whose rules you cannot see.
- [Presence system design](https://tierslate.com/templates/presence-service) - Why a green dot is a claim that expires, and why fanning it out costs more than every message sent.
- [Team channels system design](https://tierslate.com/templates/slack-channels) - Why a 30,000-member channel is not a big DM, and why the unread badge is the hardest number to keep.
- [Encrypted delivery system design](https://tierslate.com/templates/whatsapp-delivery) - What changes when the server cannot read the message, and why every tick after the first is a device claim.
- [Webhook delivery system design](https://tierslate.com/templates/webhook-delivery) - Why a webhook is a promise to keep calling until the receiver answers, and how retries avoid becoming an attack.
- [Notification router system design](https://tierslate.com/templates/notification-router) - How one event is turned into email, push or SMS by preferences and quiet hours, without sending it twice.

All 100 system design templates: https://tierslate.com/templates (Markdown: https://tierslate.com/templates.md)
