Messaging & realtime
Push notifications - the token outlives the install
Why push failures are silent, and how token lifecycle keeps a dead token from counting as delivered.
The first act plays here. 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
- 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.
- Then read the FEEDBACK band underneath it right to left - that is the direction the truth travels, hours later.
- 1 · Requirements - the questions that separate a passcode from a promotion.
- 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.
- 4 · Availability - what "delivered" can and cannot mean when the last hop is somebody else's cloud.
- 5 · How it works, then 6 · Deployment plan.
- 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
Available on Tier Slate
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.
- 5written pages
- 8walkthrough steps
- 5tables39 columns
5 pages behind this one
- Capacity estimation
- Storage estimation
- Availability
- How it works
- Deployment plan