System Design · Interview breakdown · Free article
Design a Notification System
Accept each notification once, send it by push, text, email or an in-app inbox, keep a sign-in code fast behind a sale to ten million, obey opt-outs and quiet hours, and know what actually arrived. Built one step at a time, with experiments you can run.
A notification system takes events from a company’s other services, such as “your parcel is ready”, and delivers each one to the right person by push notification, text message, email or an in-app inbox. Callers send each request with a key of their own, and the API stores it once, with an outbox row, in one transaction. Planners turn each request into one delivery per person and channel. Senders take deliveries from separate lanes per channel and priority, paced to each provider’s limit, and check opt-outs, quiet hours and the expiry just before sending. Each attempt is recorded before the provider is called, a timeout counts as unknown rather than failed, and each receipt is stored once, so the status is the furthest stage reached.
Difficulty: Medium. Reported in interviews at Airbnb, Metropolis, Amazon, Coupang, Microsoft. Also asked as Design a push notification service, Design an email notification system, Design Facebook notifications, Design a multi-channel alerting system.
Practise one part of it on a canvas that tests your design: Deliver Notifications Through a Rate-Limited Provider.
How do you design a notification system?
A notification system takes events from the rest of a company’s products, such as “your parcel is ready” or “your sign-in code is 481 902”. It delivers each one to the right person. It can arrive as a push notification on a phone, a text message, an email, or a row in a list inside the app. Every large app has one, whatever it is called. Sending one message takes a few lines of code. Sending 600 million a day is harder, because each must arrive once, while it still matters, and only to people who still want it.
- Requested: Parcel P88 is ready. The parcel service times out and asks again. Isha must get one push, not two.
- Planned: Sale: 10 million people. One request becomes ten million deliveries. None may be lost or doubled.
- Checked: Quiet from 22:00. She opted out five minutes ago. The check must run when it is sent, not when it was queued.
- Sent: Code 481 902 by text. The provider times out. Did it send? A guess either way can be wrong.
- Arrived: Delivered 18:00:09. Callbacks come twice and out of order. The status must still say what happened.
Picture Isha, who uses a large shopping app. At 18:40 her parcel reaches a locker, and the app should buzz her phone once. At 18:00 she asks for a sign-in code, and it must arrive within seconds, although marketing queued a sale for ten million people five seconds earlier. At 21:58 she turns promotional messages off, and she should hear nothing more about the sale. Three messages carry three different promises.
Interviewers like this problem because the first drawing is easy. A service calls an API, the API puts a message on a queue, and a worker calls Apple, Google or a text-message provider. The rest of the round is about what that drawing cannot promise: once, on time, only if allowed, and knowing what happened.
Here is the design in brief. Product services send each request to one notification API, with a key of their own that makes a retry harmless. The API stores the request and an outbox row in one transaction, then replies. Planners turn each request into one delivery per person and channel, and put each delivery into a lane for its channel and priority. Senders take deliveries from the lanes at the pace each provider allows. Just before calling out, a sender checks preferences, quiet hours and the expiry, and records the attempt. Receipts from the providers come back to a handler that stores each one once.
The rest of this page is about the moments that design has to survive.
The first is a timeout. The parcel service asks the API to notify Isha. The API stores the request and a push goes out, but the reply is slow. The parcel service gives up after three seconds and asks again. A careless API treats the second request as new, and Isha’s phone buzzes twice for one parcel.
The second is a queue. At 18:00 the sale queues 360,000 text messages. At 18:00:05 Isha asks for a sign-in code, and it joins the back of the same queue. The text provider takes 100 messages a second from this account, so the code goes out an hour later. It expired after ten minutes.
What is the interviewer testing?
Most candidates draw the happy path in the first ten minutes: an API, a queue, a worker per channel, and Apple’s and Google’s push services. That drawing is right, and a mid-level answer often stops there.
The interviewer then breaks it one piece at a time. A caller retries. A provider times out. A sale to ten million people lands on the same queue as a sign-in code. Somebody opts out while their message waits in line. A phone is replaced. Callbacks arrive twice. A senior answer makes acceptance safe to retry, separates priorities before the narrowest point, and checks the rules at send time. A staff answer also treats a timeout as unknown and chooses a retry rule per channel. It paces every sender to each provider account, and says what “delivered” means on each channel.
Spend most of the deep-dive time on sending: the provider timeout, then the sale and the sign-in code. How to run a round has the time plan for a 45 to 60 minute round and a 15-minute screen.
What should you ask before drawing anything?
Four questions change the design. Ask them in the first two minutes. If the interviewer leaves one open, say your assumption out loud.
- Which channels, and does one message go to all of them or to one?
- Push, text and email behave differently, and a parcel alert that buzzes, texts and emails at once is three messages. Assume push, text, email and an in-app inbox, with each category choosing its channels: a sign-in code by text, a parcel alert by push plus the inbox.
- One person at a time, or campaigns to millions?
- A parcel alert names one person. A sale names an audience, and one request becomes millions of deliveries. Assume both: single notifications all day, and a few campaigns of up to 10 million people.
- Which messages are urgent, and how urgent?
- A sign-in code is useless after ten minutes, and the person is staring at the screen. A sale can take an hour. Assume codes must start sending within five seconds, even during a campaign.
- Who decides what a person may receive?
- Opt-outs, quiet hours and caps such as three promotions a day. Assume the notification system owns preferences and enforces them, so no product team has to remember them.
Functional requirements
1. Notify one person, or an audience up to 10M 2. Push, text, email and an in-app inbox 3. Obey opt-outs, quiet hours and daily caps 4. Send later; drop once no longer useful 5. Report each delivery’s status out: campaign builder, ranking, content
Say it, don’t write it: Sending is the easy part. The hard part is sending each one once, on time, and only when the person still wants it.
The users are two groups. Product teams send notifications through one API instead of each calling Apple, Google and a text provider themselves. The people receiving them notice three things: a message that arrives twice, a message that arrives too late to use, and a message they asked not to get.
- Accept a notification for one person, or for an audience of up to 10 million, through one API.
- Deliver it by push notification, text message, email or an in-app inbox, according to its category.
- Obey each person’s opt-outs, quiet hours and daily caps on promotions.
- Send at a scheduled time, and drop a notification once it is no longer useful.
- Let the caller see what happened to each delivery: sent, delivered, failed or skipped, and why.
Out of scope
- Building campaigns and choosing audiences, beyond receiving a fixed list of people
- Ranking which notifications a person should get at all, as large social apps do
- Writing the words, beyond templates with placeholders
- Live updates inside an open app over a socket, which the chat system breakdown covers
Non-functional requirements
• 100M users × 6 a day = 600M/day ≈ 7k/s • 10M campaign: ≥ 17 min at FCM’s 600k/min • Sign-in codes start sending in < 5 s • Accepted = never lost, never sent twice by us • An opt-out applies to every later send • Status kept 30 days
Say it, don’t write it: The average is easy. Campaigns set the peak, and the providers’ limits set how fast anything can leave.
- About 600 million deliveries a day, about 7,000 a second on average.
- A campaign to 10 million people goes out as fast as the providers allow.
- A sign-in code starts sending within 5 seconds, even while a campaign is running.
- An accepted notification is never lost, and our own retries never send it twice.
- An opt-out applies to every send checked after it.
- The status of each delivery is kept for 30 days.
Two numbers are worth working out now, because each decides a piece of the design. The first is the average. 100 million daily users receiving about 6 notifications each is 600 million deliveries a day. A day has 86,400 seconds, so that is about 7,000 a second. A few machines handle that.
The second is the campaign, and a provider sets its speed. Say the app sends all its pushes through Google’s Firebase Cloud Messaging (FCM), which also delivers to iPhones through Apple’s push service. FCM’s default quota is 600,000 messages a minute per project (Firebase), which is 10,000 a second. Ten million pushes take at least 10,000,000 ÷ 10,000 = 1,000 seconds, about 17 minutes, however many machines we run. So the API must never send anything itself. It stores the request and replies, and queues hold the campaign while the providers set the pace.
The other numbers appear in the deep dive that needs them. They are illustrative interview targets, not measurements of any particular app.
Core entities
Notification(id, caller, key, category, expiry) Delivery(notification, user, channel, state) Attempt(delivery, n, provider id, result) Receipt(delivery, stage, provider event) Preferences(user, category → channels, quiet) Device(user, push token, last registered)
Say it, don’t write it: One request can mean millions of deliveries, and one delivery can take several attempts. Each gets its own ID.
Follow Isha’s parcel alert through the records. The parcel service sends a request with its own key, ev-88. The API stores it as notification N1. N1 holds the category “order update”, the template “parcel ready” version 4, the parcel number as a parameter, and an expiry two days away.
A planner then turns N1 into deliveries, one per person and channel. Order updates go by push plus the in-app inbox, so N1 becomes two deliveries for Isha: d1 by push and d2 into her inbox. A sale works the same way, except that one notification becomes about 10 million deliveries.
A sender takes d1, records attempt 1, and calls the push service. Later, providers that report back send receipts, and each is stored against its delivery.
| Record | What it holds | Why it is separate |
|---|---|---|
| Notification | The caller, its key, the category, the template with its parameters, the expiry | One per request; the key lets a retried request find it |
| Delivery | One person, one channel, and its state | A sale is one notification and 10 million deliveries |
| Attempt | Each call to a provider, written before the call, with the provider’s message ID | A timeout needs a record of what may have gone out |
| Receipt | What a provider reported later: sent, delivered, bounced | Callbacks repeat and arrive out of order |
| Preferences | Per category: allowed channels; quiet hours; a time zone | Read again just before each send |
| Device | One push token per app install, and when it was last registered | A person has several devices, and tokens die |
Two distinctions matter. A notification is what a product asked for, and a delivery is what one person gets on one channel. Keeping them apart is what lets one request reach 10 million people and still say, for each of them, what happened.
The other is between an attempt and a receipt. An attempt is our own record, written before we call a provider, so it survives even if the call never returns. A receipt is the provider’s word. It arrives later, and sometimes twice.
API
POST /notifications (Idempotency-Key)
{category, template, params, to|audience}
→ 202 {id}
GET /notifications/:id/deliveries?cursor=
PUT /users/:id/preferences
POST /receipts/:provider (signed)Say it, don’t write it: The API answers 202 once the request is stored. It never waits for Apple or a phone.
Product services call one endpoint. The rest serves status, preferences, devices and the providers’ callbacks.
| Call | Returns | Why it looks like this |
|---|---|---|
POST /notifications with header Idempotency-Key: ev-88 | 202 and the notification’s ID, once it is stored | The same key from the same caller returns the same ID, so a retry is safe |
Its body: category, template, params, to or audience_id, send_at, expires_at | Nothing more | The category decides channels and rules; the expiry says when it stops being useful |
GET /notifications/{id}/deliveries?cursor= | A page of deliveries, each with its state and reason | A campaign has 10 million deliveries, so it pages |
PUT /users/{id}/preferences | The new preferences and their version | Senders read these just before each send |
POST /users/{id}/devices {token, platform} | Nothing | The app registers its push token every time it starts |
POST /receipts/{provider} | 200 once the receipt is stored | Providers call this, and each call is checked against the provider’s signature |
Three fields exist for a reason. The key comes from the caller, because only the caller knows that two requests describe the same event. The template carries a version, parcel_ready@v4, so a retry renders the same words even if someone edits the template in between. And expires_at lets the system drop a notification that has become useless, instead of delivering it late.
Why 202 rather than 200? The API has stored the request and promises to work on it. It has not sent anything yet, and for a campaign the sending takes at least 17 minutes. A caller that wants to know more reads the deliveries.
Step 1: accept a notification once and store it
Start with acceptance. The parcel service calls POST /notifications. The API checks that this caller may use this category, that the template exists and the parameters fill it, and that the recipient exists. Then it stores the request in the notification store and replies 202 with its ID.
The store is PostgreSQL, and one transaction writes two rows: the notification, and a row in an outbox table that says “this needs planning”. A unique index on the caller and its key means a retried request finds the first one instead of making a second. The first deep dive shows why that check belongs inside the transaction.
Most notifications are one request for one person, so the store takes a few thousand inserts a second. A campaign is one row, however many people it reaches. Rows are kept for 30 days, and a nightly job deletes older ones in small batches. The unique index then covers every row the store holds, so a key stays unique for all 30 days. The store is still several terabytes, more than one machine should carry, so the store is split across shards by a hash of the caller and the key. A retry carries the same caller and key, so it always reaches the shard that holds the first request.
The interactive version of this example is available when JavaScript loads.
The API keeps no state of its own, so any instance can take any request. The 202 means one thing: the request is stored and will be worked on.
Step 2: plan deliveries, and send each channel through its own lane
A relay reads new outbox rows and publishes each notification to a Kafka topic. Writing to Kafka straight after the commit would be simpler. But if the API died between the two writes, the notification would be stored and never sent. The outbox row commits with the notification, so the relay can always catch up.
Planners read the topic. For a notification to one person, a planner reads that person’s channels and contact details from the preferences store. It writes one delivery per channel into the delivery log. For a campaign, it reads the audience in pages of 1,000 people, sorted by user ID. It writes 1,000 deliveries per page and records the last user ID of each finished page, so a planner that dies restarts from the last finished page. A delivery’s ID is built from the notification, the person and the channel, so a page done twice writes the same deliveries again instead of new ones.
Each delivery then goes into a lane: a Kafka topic per channel and priority, such as “push, urgent” or “text, bulk”. Senders read the lanes. A push sender calls FCM or Apple’s push service (APNs). A text sender calls an SMS provider, and an email sender calls an email provider such as Amazon SES. The in-app inbox is a channel too, but its sender writes a row into a store we own instead of calling anyone.
The delivery log is where the numbers get large. Each delivery, with its attempts and receipts, is about 1 KB. 600 million a day for 30 days is 600,000,000 × 1,000 bytes × 30, about 18 TB before copies. So the log is a Cassandra cluster, split by delivery ID, and every row expires after 30 days on its own. The inbox is a Cassandra table too, split by person.
The interactive version of this example is available when JavaScript loads.
This works on a quiet day, while every provider answers and nobody changes their mind.
Step 3: check the rules at send time, and hold what is early
The planner uses a person’s preferences to pick channels. The sender checks them again, immediately before calling a provider, because a delivery can wait in a lane for minutes or hours. Preferences live in PostgreSQL, with a copy of each person’s in Redis, which every sender reads. When Isha changes a setting, the preferences service writes PostgreSQL and then replaces her copy in Redis.
The sender checks four things. Does this person still accept this category on this channel? Is it inside their quiet hours, in their own time zone? Have they already had their three promotions today? Is it past the notification’s expiry?
Some deliveries must wait. A notification with a send_at in the future, or a promotion that lands in quiet hours, goes to a scheduler instead of a provider. The scheduler holds each delivery until its time, then puts it back in its lane, where the sender checks everything again. The job scheduler breakdown shows how to build one that never loses or doubles a job.
The interactive version of this example is available when JavaScript loads.
Checking at send time is what lets a person change their mind after a message is queued. The deep dives show what that costs and what it still cannot stop.
Step 4: store what the providers report
Several providers report later what happened. An SMS provider calls back when the carrier accepts a text, and again when the carrier confirms delivery. An email provider reports deliveries, bounces and complaints. Apple’s push service sends no report at all after it accepts a notification. Callbacks arrive at a receipt handler, which checks the provider’s signature, stores the receipt under its delivery, and replies 200.
The status endpoint reads the delivery log. For one parcel alert it returns two deliveries. For a campaign it has to page through 10 million, and the log is split by delivery ID, which cannot answer “every delivery of N1” in one place. So the senders also write each delivery into a second table, split by notification ID and a bucket number. They raise a counter per state and reason too, and the dashboard reads those counters.
The interactive version of this example is available when JavaScript loads.
With a few thousand users this is already a working notification system. The deep dives take it through retries, timeouts, a sale to 10 million, changed minds, new phones and callbacks that repeat.
The parcel service sent the same request twice. Does Isha get two pushes?
At 18:40:02 Isha’s parcel P88 reaches a locker. The parcel service calls POST /notifications to tell her. The API stores the request as N1, and a push goes out. But the database is busy for a moment, and the reply takes four seconds. The parcel service stopped waiting after three.
From where the parcel service sits, two things could have happened. The request may never have arrived, or it may have been stored with its reply lost. Both look the same: a timeout. So at 18:40:07 it sends the request again.
The simplest API stores every request it receives. The retry becomes N2, a second push goes out, and Isha’s phone buzzes twice for one parcel. Once, that is harmless. Now make it a bank app, and the message “Your payment of £50 was received” arriving twice. People ring the bank.
The next idea is to drop a request if the same person got the same words in the last 10 minutes. The retry is dropped. Then at 18:46:30 a second parcel, P91, reaches another locker. Its alert says “Your parcel is ready for pickup”, because every parcel alert does. The API drops it too, and Isha never hears about her second parcel. Words cannot tell a retry from a second event that happens to read the same.
Only the caller knows whether two requests describe the same event. So the caller sends a key with each request, one per event. The parcel service already has one: the ID of the event “parcel P88 is ready”, ev-88. It sends it in the Idempotency-Key header, the same key on every retry. The API stores the key with the notification, and a unique index on the caller and the key means ev-88 can be stored once.
Replay the timeout. The first request stores N1 under ev-88, and the reply is slow. The retry arrives with ev-88. The API finds it, sees N1, and replies 202 with N1 without storing or sending anything. Parcel P91’s alert arrives with its own key, ev-91, and becomes N2. Isha gets one push per parcel.
Now suppose the retry arrives while the first request is still being stored, which happens when a caller retries quickly. If the API looked the key up first and inserted afterwards, both requests could look, both find nothing, and both insert. So the lookup and the insert are one statement: INSERT … ON CONFLICT (caller, idem_key) DO NOTHING. At PostgreSQL’s default isolation level, read committed, the second insert of ev-88 waits until the first commits, then does nothing and returns no row. The API then reads the first one’s ID in a new statement. The outbox row is written only by the insert that succeeded, in the same transaction, so a retry can never queue a second plan.
One more rule catches a caller’s mistake. The API stores a short fingerprint of the request’s contents with the key. If ev-88 comes back with different contents, say a different person, the API answers 422. That is the code the IETF’s draft standard for the Idempotency-Key header recommends for a key reused with a different body (IETF). A key reused for a new event is a bug in the caller, and it should be loud.
How long must a key be remembered? As long as a caller might retry. A parcel service with its own outbox can resend an event hours later, after a crash. A cache that forgets keys after ten minutes reopens the duplicate for any retry after that. Here the key is a column of the notification row, so it lives as long as the notification does: 30 days.
Acceptance is not the only place a notification can double. A planner can die halfway through a campaign page, and a new planner redoes the page. A sender can die after calling a provider and before recording it, and Kafka hands the job to another sender. Each step needs its own answer.
The planner’s answer is the delivery ID. It is built from the notification, the person and the channel, so a page done twice writes the same 1,000 IDs, and the second write changes nothing. The sender’s answer is the attempt, recorded before the call, and the next deep dive shows why that is harder than it looks. The network, the queues and the callers all deliver at least once. The keys and IDs make each effect happen once (idempotency).
The experiment replays the timeout three ways. The tabs are an API that stores every request, one that drops repeated text, and one that checks the caller’s key.
The interactive version of this example is available when JavaScript loads.
The gap: The caller cannot tell a lost request from a lost reply, so it must retry, and the API must recognise the retry.
Option 1: Store every request
The API stores and sends whatever arrives.
Works when: Never, because every caller retries.
Breaks when: Every slow reply becomes a second message.
Option 2: Drop the same words for ten minutes
The API compares each request with what the person recently received.
Works when: Only for a caller that never sends two real events with the same words.
Breaks when: A second, real event with the same words is dropped, and nobody is told.
Option 3: A key from the caller, unique in the store (start here)
The caller sends one key per event; a unique index on caller and key turns a retry into a lookup.
Works when: Always.
Watch for: Callers must send a real event ID and reuse it on every retry; a changed body under the same key gets 422.
In the interview: Open with option 3, and say what 202 means: stored, once. Use option 2 to show that words cannot tell a retry from a repeat. Then name the other places a notification can double, the planner and the sender, and give each its own ID.
Say this: A caller cannot tell a lost request from a lost reply, so it retries. Each request carries a key the caller already has, the event’s ID, and a unique index on the caller and the key turns a retry into a lookup that returns the same notification. Only the insert that wins writes the outbox row, so a racing retry cannot plan it twice. Deliveries get IDs built from the notification, the person and the channel, so a planner that redoes a page changes nothing.
The interactive version of this example is available when JavaScript loads.
The code has four tabs. They are the accepting transaction from this deep dive, the sender from the next, the shared rate limit from the sale, and the receipt table from the last.
The text provider timed out. Did Isha’s sign-in code go out?
At 18:00:05 Isha taps “Send me a code”. The sign-in service creates the code 481 902 and asks for a notification in the category “sign-in code”, which goes by text message. A sender picks up the delivery, d7, and calls provider A.
Provider A accepts the message and hands it to the mobile carrier. A second later the text is on Isha’s phone. But A’s answer to the sender, “accepted, message SM91”, is lost on the way back. At 18:00:15 the sender’s 10-second timeout fires.
The sender now knows less than it seems. Two histories fit what it saw. In one, A never received the request. In the other, A accepted it and the reply died. From the sender’s side both look the same: silence. So the honest state for d7 is “unknown”, and calling it “failed” is a guess.
The usual retry loop makes that guess. It calls the delivery failed and tries again. A sends the code a second time, and Isha has two identical texts. For a sign-in code that is a small annoyance and a small cost, since each text is billed. For “Your payment of £50 was received”, a second copy makes people wonder whether they paid twice.
Failing over is the same mistake with a second provider. A looks slow, so the sender tries provider B. B sends the code too, from a different number, and Isha has the same code from two numbers she does not recognise. Switching providers after a timeout doubles a message as surely as a retry does. Failover has its place, after a definite failure or while A is known to be down, because then A has certainly sent nothing.
Could the provider spot the retry, the way our API spots the parcel service’s? Only if it accepts a key of ours on the call that sends. Neither Twilio’s message API nor Amazon SES’s SendEmail call has one (Twilio, Amazon SES). Twilio’s own debugging guide says a duplicate message “almost always” means the application sent two requests (Twilio). For text and email, then, a blind retry is never safe.
The opposite rule, never retrying a timeout, fails in the other history. If A never got the request, Isha waits for a code that will never come. Neither blind rule is right. The sender needs evidence.
The first piece of evidence is its own record. Before calling out, the sender writes attempt a1 for d7 into the delivery log, in state “sending”. Now a crash, a timeout or a redelivered job all find a1 and know a call may be out there. A second sender that picks up d7 after a crash sees a1 and does not call A on its own.
The second piece of evidence comes from the provider. An SMS provider such as Twilio accepts a status callback address with each message, and calls it as the message moves: sent to the carrier, delivered, or failed. The sender puts its own attempt ID in that address: /receipts/sms-a?attempt=a1. If A accepted the request, its callback carries a1, although the sender never learned A’s message ID. A is slow today, which is why its reply timed out, and its callbacks are slow too. At 18:00:21 one arrives: attempt a1, delivered. d7 moves from unknown to delivered, and nothing is sent twice. Had the callback come before the timeout, the sender would have found it in the log when the timeout fired, and never called d7 unknown at all.
If no callback comes within two minutes, the sender asks A directly. Twilio lets you list messages by the number sent to, the number sent from and the date, which finds a text even without its ID. If A shows the text, d7 takes its status. If A has no record of it, the request never arrived, and the sender sends the code again.
Some providers offer no such lookup. Then an unknown that no callback settles stays unknown, and the category decides. A sign-in code gets one more attempt, because a missing code locks Isha out and a duplicate costs a few pence. A payment receipt gets none, and waits for a person to look.
Push is kinder. Apple’s push service takes an apns-collapse-id header. Apple’s own instruction for it is: “When sending the same notification more than once, use the same value in this header to merge the requests” (Apple). On Android the matching tool is the notification’s tag: a notification with the same tag replaces the one already shown (Firebase). The sender uses the delivery ID as both. A retry after a timeout may then reach the phone twice, but Isha sees one notification, although the phone may sound twice. Text and email have nothing like it. So the retry rule is set per channel: push retries a timeout with its collapse ID, and text and email wait for evidence.
Most failures are not unknown at all. A provider that answers “invalid number” or “too many requests” has given a definite answer: nothing was sent. An invalid number is never retried, and the delivery is marked failed with the reason. FCM, for example, asks senders not to retry its 400, 401, 403 and 404 errors (Firebase). “Too many requests” is retried after a pause, and only within the notification’s expiry. The pause carries random jitter, so that twenty senders do not all come back in the same millisecond. The unknown state exists for one case: the answer never came.
The experiment replays the timeout three ways. The tabs are retrying it, failing over to provider B, and recording the attempt before waiting for evidence.
The interactive version of this example is available when JavaScript loads.
The gap: A timeout means the provider may or may not have sent the message, and the sender cannot tell which.
Option 1: Retry after a timeout
Treat a timeout as a failure and call the same provider again.
Works when: Push, when the retry carries the same collapse ID or tag.
Breaks when: Texts and emails arrive twice, and each copy is billed.
Option 2: Fail over to a second provider
Treat a timeout as a sick provider and send through another.
Works when: After a definite failure, or when the first provider is known to be down.
Breaks when: After a timeout, the first may have sent it too, so two copies arrive from two numbers.
Option 3: Record the attempt, then wait for evidence (start here)
Write the attempt before the call, mark a timeout unknown, and settle it from the callback or a lookup.
Works when: Always, and it is the only safe choice for text and email.
Watch for: An unknown needs a callback or a lookup within minutes; where neither exists, the category decides whether it gets one resend.
In the interview: Open with option 3, and name the two histories a timeout hides. Say that the retry rule differs by channel: push can retry with a collapse ID, text and email cannot. Keep option 2 for a provider that fails definitely or is down.
Say this: A timeout hides two histories: the provider never got the request, or it sent the message and the reply was lost. So the sender writes the attempt before calling, marks a timeout as unknown rather than failed, and puts the attempt ID in the status callback address, so the provider’s callback settles it. If no callback comes, the sender looks the message up at the provider. Where no lookup exists, the category decides: a sign-in code gets one resend, a payment receipt does not. Push can retry, with the delivery ID as its collapse ID.
A sale goes out to 10 million people. Why does Isha’s sign-in code take an hour?
At 18:00 marketing sends the weekend sale to 10 million people. Most have the app and get a push. The 360,000 who do not get a text message instead. The planners write all 360,000 text deliveries into the text lane in the first few seconds.
At 18:00:05 Isha asks for a sign-in code. Her delivery is written into the same text lane, behind the sale. The app sends texts from a short code, a five- or six-digit number made for high volume, and its provider account takes 100 texts a second. Short codes typically start at 100 a second (Twilio). The senders use every one of them.
Do the arithmetic Isha cannot see. In its first five seconds the sale sends 500 texts, so 359,500 are ahead of her code. At 100 a second that is 3,595 seconds, just under an hour. Her code goes out at 19:00:00. It expired at 18:10:05, ten minutes after she asked. By then she has given up, or asked for three more codes, each joining the back of the same line.
The first instinct is more senders. Go from 20 to 200. Nothing changes. The provider takes 100 texts a second from this account, whoever asks, and the code still goes out at 19:00. Some providers answer the extra calls with “429 Too Many Requests”. Twilio accepts them and queues them itself, sending at the account’s rate (Twilio). Then the code waits the same hour in Twilio’s queue instead of ours, where we can no longer reorder it. The narrowest point is the provider’s limit, so priority has to be decided before a message is handed over.
It is worth knowing how many senders the limit actually needs. If one call to the provider takes about 200 milliseconds, keeping 100 calls a second going needs 100 × 0.2 = 20 calls in flight at once. One machine holds that. Anything more waits in line at the provider.
So the fix has to happen before the provider, in the order work is taken. Give sign-in codes their own lane, read by a few senders of their own, so a code never waits behind a sale text. On an ordinary evening the app sends about 5 codes a second. Codes now take about 5 of the 100 texts a second, and the sale gets the other 95.
Replay the evening. Isha’s code is written into the codes lane at 18:00:05, and the next free slot is hers. It goes out at once and is on her phone within a second or two. The sale gets 95 texts a second instead of 100, so it finishes at 19:03:09 instead of 19:00:00.
Kafka has no priority between topics, so the lanes get their priority from who reads them. The codes lane has senders of its own that never touch a sale text.
That creates a new problem. The 100 a second belongs to the provider account, and both groups of senders share it. If each sender limited itself to its own slice, a quiet sender would waste its share while a busy one queued. And the twenty sale senders would take every token the moment it appeared, so a code sender would still wait its turn among them. So the limit lives in one place: a token bucket in Redis for the account, filled at 100 tokens a second. Every sender takes a token from it before each call (distributed rate limiting). The bucket keeps its last 10 tokens for codes. A sale sender takes a token only if 10 would still be left, while a code sender may take the last one. Codes never wait behind the sale.
A flood of codes could still take all 100, from a bug or from someone requesting codes for numbers they do not own to run up the bill. So codes have limits of their own, a few per phone number per hour, enforced where the code is requested.
Why not simply serve the urgent lane first, for everything important? Because priority is a promise about order, and it can starve. If order updates, social alerts and codes all counted as urgent, a busy afternoon could hold the sale back for hours. Keep the urgent lane small and narrow: codes, security alerts, messages someone is waiting for. Everything else shares by weight, so order updates might get three slots for every one the sale gets.
Large senders go one step further and give urgent traffic its own sender identity. Codes get a separate number, and receipts and password-reset emails get a separate sending domain and IP address. The limit, and the reputation, then belong to each stream on its own. Gmail asks bulk senders to keep the spam rate it measures below 0.10% and never to reach 0.30% (Google). If the sale earns complaints, the password resets should not pay for them. Each new identity must be registered, and a new email address or number is warmed up with small volumes before it carries a campaign.
Push has the same shape at a larger size. The sale’s 9.64 million pushes leave at FCM’s 10,000 a second, which takes 964 seconds, about 16 minutes. The same lanes and the same shared bucket apply. Google also asks senders to avoid the two minutes around :00, :15, :30 and :45, when everyone else’s scheduled sends land (Firebase). So a sale planned for 18:00 is better started at 18:03.
The experiment replays the evening. The tabs are one queue, ten times as many senders, and a lane for codes.
The interactive version of this example is available when JavaScript loads.
The gap: The provider’s limit is the narrowest point, so whatever waits ahead of a message decides when it leaves.
Option 1: One queue per channel
Every text waits in one line, first in, first out.
Works when: A channel with no campaigns and no urgent messages.
Breaks when: A sale of 360,000 texts puts an hour in front of a sign-in code.
Option 2: More senders
Add workers until the queue drains faster.
Works when: Only while the provider accepts more than the senders send.
Breaks when: Past the limit, extra calls get 429s, or wait in the provider’s own queue where we cannot reorder them.
Option 3: Lanes by priority, and one shared limit per account (start here)
Codes get a small lane and senders of their own; everything else shares the rest by weight, through one token bucket that keeps a reserve.
Works when: Once one channel carries both campaigns and urgent messages.
Watch for: The urgent lane must stay small, and codes need a per-number limit so a flood of them cannot starve the rest.
Option 4: A separate sender identity for urgent traffic
Codes and security emails go out from their own number, domain and IP address, with their own limit.
Works when: Large senders, or when marketing complaints start to hurt delivery of receipts.
Watch for: Each identity must be registered, warmed up and paid for.
In the interview: Open with option 3, and do the arithmetic for option 1 first: 360,000 texts at 100 a second is an hour. Say why option 2 changes nothing, and that a provider’s own queue hides the same hour, then add option 4 when the interviewer asks about email reputation or scale.
Say this: The provider takes 100 texts a second from our account, so a sale of 360,000 queued ahead of a sign-in code delays it by an hour, and more senders change nothing. Codes get a small lane with senders of their own, and everything else shares the rest by weight. All senders take tokens from one bucket per provider account in Redis, which keeps a reserve for codes. Codes also have a per-number limit, so a flood of them cannot starve the rest.
Isha opted out at 21:58. Why did the sale reach her at 22:03?
At 21:30 marketing queues a text for everyone who accepts promotions: “Flash sale ends at midnight”. The sale lane takes a while to drain, and it reaches Isha’s place in the line at 22:03. At 21:58, tired of sale messages, Isha turns promotions off. At 22:03 the text arrives anyway.
The planner checked her preferences at 21:30, when it wrote her delivery, and she accepted promotions then. Nothing looked again. Omar, another customer on the same list, has quiet hours from 22:00 to 08:00, and his phone buzzes at 22:03 too.
Every rule about whether to send must be checked when sending, not when queuing. The sender reads Isha’s preferences from Redis just before calling the provider, sees promotions switched off, and marks her delivery “skipped: opted out”. The check costs one Redis read per delivery. During a campaign that is at most about 10,000 reads a second, which a small Redis cluster handles easily.
The order of the writes matters. When Isha opts out, the preferences service writes PostgreSQL first, then replaces her copy in Redis, and only then tells her it is done. If the Redis write fails, it retries before answering. Each copy carries the preferences version, so a slow, older write can never replace a newer one. A sender that reads after the replacement skips her. A sender that read a moment before, and is already calling the provider, still sends. So an opt-out stops every send checked after it, and one message already on its way can still arrive. An interviewer will ask about this. The law allows for it. The United States rule for telephone solicitations, generally applied to marketing texts, gives a business up to ten business days to honour a request to stop (47 CFR 64.1200). Yahoo asks bulk email senders to honour unsubscribes within two days (Yahoo). The design honours it within seconds.
Opt-outs also arrive from outside. A person can reply STOP to a text. The carrier and the SMS provider then block further texts to that number and report the reply, and the preferences service records it. Bulk email carries a one-click unsubscribe link, which Gmail requires of bulk senders (Google), and the request it sends lands in the same preferences.
Quiet hours use the person’s own clock. Omar’s preferences store a named time zone, Europe/London, rather than an offset such as +01:00. A named zone follows the clocks when they go back in October, and an offset does not. Take late September, while Britain and the United States are both on summer time. A campaign sent at 21:30 in London is 16:30 in New York and 04:30 in Singapore. The same send is fine for one person and inside quiet hours for another. The same rule protects the company too: that United States rule allows marketing calls only between 8 a.m. and 9 p.m. at the recipient’s location.
When the check finds Omar inside his quiet hours, the sender does not drop the text. It hands the delivery to the scheduler with a new time, 08:00 his time, and the scheduler puts it back in the lane then. Everyone held overnight in one time zone becomes due at 08:00. So the scheduler spreads their release over the next half hour instead of dropping them all into the lane at once.
That creates a new problem. At 08:00 Omar’s phone buzzes: “Flash sale ends at midnight”. The sale ended eight hours ago. The system obeyed every rule and still sent something wrong, because it knew when a message may be sent but not when it stops being worth sending.
So every notification carries an expiry, set by the caller who knows what the message means. It is midnight for this sale, ten minutes for a sign-in code and two days for a parcel alert. The sender checks it like any other rule. At 22:03 it finds Omar in quiet hours and works out the next moment it may send, 08:00. That is past the midnight expiry, so it drops the delivery at once and records “expired” with the reason.
Caps are the same kind of rule. Isha accepts promotions, but no more than three a day. Each promotional send raises a counter in Redis for her and the day, and the sender skips the delivery once the counter passes three. The counter is raised and read in one atomic step, INCR, so two campaigns reaching her in the same second cannot both see “two so far”. The counter expires at her local midnight. A promotion that passes the check and then fails still counts, which errs towards sending fewer.
The same check handles a product that changes its mind. If Isha collects parcel P88 before the push goes out, the parcel service cancels N1, and every sender that checks after that skips its deliveries.
The experiment runs the night for Isha and Omar. The first tab checks when the text is queued. The second checks when it is sent and holds it for quiet hours, and the third checks when it is sent, with an expiry.
The interactive version of this example is available when JavaScript loads.
The gap: A delivery can wait minutes or hours in a lane, and both the person’s wishes and the message’s usefulness can change while it waits.
Option 1: Check when queued
The planner checks preferences and quiet hours as it writes each delivery.
Works when: Messages that leave within seconds of being planned.
Breaks when: An opt-out, or quiet hours that begin while it waits, are ignored.
Option 2: Check when sending, and hold for quiet hours
The sender checks just before calling out, and reschedules anything inside quiet hours for the morning.
Works when: Messages that stay true for days, such as a weekly summary.
Breaks when: A message held past its point arrives when it is already wrong.
Option 3: Check when sending, with an expiry on every notification (start here)
The sender checks preferences, quiet hours, caps and the expiry; a hold past the expiry drops the delivery with a reason.
Works when: Always.
Watch for: A send already past its check can land a moment after an opt-out, so say so; callers must set honest expiries.
In the interview: Open with option 3, and name the four checks: preferences, quiet hours in the person’s zone, caps and the expiry. Say what an opt-out can and cannot stop, and give an expiry for each category.
Say this: Rules change while a delivery waits, so the sender checks them just before calling the provider: preferences from Redis, quiet hours in the person’s own time zone, a daily cap counted with INCR, and the notification’s expiry. A delivery inside quiet hours goes back to the scheduler, unless the next allowed time is past its expiry, in which case it is dropped and logged. An opt-out stops every send checked after it; one already on its way can still arrive.
Isha replaced her phone. Where do her pushes go?
A push notification goes to an app install, not to a person. When the shopping app starts on Isha’s iPhone, it asks Apple for a device token: a long string that means “this app, on this phone”. The app sends the token to the notification system, which stores it against Isha. To send her a push, a sender hands the push service the token and the message. Her tablet runs Android, so its token comes from FCM.
The simplest store has one token field on the user row. Isha’s phone registers token tA. That evening she opens the app on her tablet, which registers tB over tA. Her phone stops getting pushes, and nothing tells anyone. Whichever device opened the app last wins. So the store keeps a row per token: Isha has tA and tB, and a push goes to both.
On Saturday she buys a new phone and restores her apps onto it. The app on the new phone asks Apple for a token and registers tC. The old phone is wiped. The server now holds three tokens for her, and one of them reaches nothing.
Apple says so the next time a sender uses it. It answers the push for tA with status 410 and the reason “Unregistered”: the device token is inactive for this app. FCM answers a dead token with an error called UNREGISTERED (Apple, Firebase). The sender must remove it, because a service that keeps pushing to dead tokens wastes calls on every notification.
A tidy-minded handler clears all of Isha’s tokens on such an error, to make her devices register again. tB and tC go with tA. Her tablet and new phone get nothing until she happens to open the app on each. The fix is narrow: delete the row whose token is exactly tA, and nothing else.
One race is left. Apple’s 410 carries a timestamp: the time Apple confirmed the token was no longer valid. If the app registered that same token again after that moment, the error is stale, and the row stays. So the handler deletes tA only if its row was last registered before Apple’s timestamp.
Not every dead token says so. A phone left in a drawer keeps a token that never receives anything. Google calls a registration stale once its device has not connected to FCM for over a month, and Android tokens inactive for 270 days expire (Firebase). So the app registers its token every time it starts, and the row records when. A nightly job removes tokens nobody has registered in 270 days, when Google expires an inactive Android token anyway. A shorter sweep would delete the live tokens of people who have not opened the app lately. They are the people a push is meant to bring back. A stale token wastes a call. It never loses a notification, because pushes are not the record.
That last point matters more than the tokens. A push is a nudge. Apple and Google treat delivery as best effort, and a phone that is off receives nothing until it comes back. So everything that matters also lands in Isha’s in-app inbox: a row per notification in a Cassandra table, split by person, newest first. When she opens the app on her new phone, it reads her inbox and shows everything, whatever happened to the pushes.
The number on the app’s icon comes from the inbox too. A separate counter that goes up on each notification and down on each read drifts. A retried write adds two, and a phone that keeps its own count never hears about a read on the tablet. Instead Isha has a read marker, the time she last opened her inbox, and the badge is the number of inbox rows newer than it. On an iPhone the badge in a push payload is an absolute number, not an increase (Apple), so the sender counts it from the inbox at send time.
The experiment follows Isha’s tokens through the week. The tabs are one token per user, clearing all her tokens on an error, and a row per token.
The interactive version of this example is available when JavaScript loads.
The gap: A person has several app installs, each with its own token, and tokens die without warning.
Option 1: One token per user
The user row holds the latest token.
Works when: An app nobody uses on two devices.
Breaks when: The last device to open the app takes every push.
Option 2: Every token, cleared on any error
Keep all of a person’s tokens; wipe them all when one fails.
Works when: Never, because a dead token takes live ones with it.
Breaks when: One wiped phone silences every other device.
Option 3: A row per token, deleted by exact match (start here)
Register on every start; delete only the token that failed, unless it was registered after the provider’s timestamp; sweep tokens unused for 270 days.
Works when: Always.
Watch for: Pushes can still be dropped by the platform, so the inbox, not the push, is the record.
In the interview: Open with option 3, and say that a token belongs to an app install. Mention the 410 Unregistered answer, the timestamp check and the sweep. Then say that the inbox is the record and the push only a nudge, and count the badge from a read marker.
Say this: A push token belongs to one app install, so the store keeps a row per token and a push goes to each of a person’s devices. When Apple answers 410 Unregistered, or FCM answers UNREGISTERED, the sender deletes exactly that token, unless it was registered again after the provider’s timestamp. A sweep removes tokens not registered in 270 days. Pushes can be dropped, so every notification also lands in the in-app inbox, and the badge is the count of inbox rows newer than the person’s read marker.
The dashboard says 102% delivered. What does “delivered” mean?
The sale is over, and the marketing dashboard says 367,200 texts delivered out of 360,000 sent. That is 102%. Meanwhile some customers who clearly got the text show as “sent”, never delivered. Both numbers come from the provider’s callbacks, and both are wrong for the same reason.
Follow one sale text, the one to Omar. Provider A calls the receipt handler as the text moves. It sends “sent” at 18:20:04, when the nearest carrier accepts the text, and “delivered” at 18:20:07, when the carrier confirms his phone has it. Then two things happen that callbacks commonly do. The handler was slow to answer the “delivered” call, so A sends it again at 18:20:38. And the first “sent” call, which the handler also answered too slowly, is retried at 18:21:08, after the delivered one. Twilio says plainly that there is no guarantee its status callbacks arrive in the order they were sent (Twilio).
The simplest handler keeps one status column and overwrites it with each callback. After the last one, Omar’s text says “sent”, although it reached his phone a minute earlier. And the dashboard counts “delivered” each time the callback arrives, twice for his text. Across a campaign, repeats push the count past 100% while late callbacks make delivered texts look stuck.
Two changes fix both numbers. First, store each receipt as its own row under the delivery, keyed by the delivery and the stage. A repeated “delivered” lands on the row it repeats and changes nothing, so it cannot be counted twice. Second, the status is the furthest stage any receipt has reached: queued, then sent, then delivered. A late “sent” is stored, but it cannot move the status back. Replay Omar’s four callbacks: two rows, and the status stays “delivered”. The dashboard counts deliveries whose furthest stage is “delivered”, once each.
A failure is not a further stage. An “undelivered” from the carrier is stored as its own receipt and shown beside the furthest stage: sent, then undelivered. So is an email bounce that arrives after the mail server took the message.
Cassandra suits this. The receipts table has the delivery ID as its partition key and the stage as its clustering key, furthest first, so reading the status is reading one row. No read-then-write is needed, because a repeat is just the same row written again.
Two checks come before any of this. The handler must know which delivery a callback is about. The attempt ID in the callback address tells it, even for a callback that arrives before the provider’s own reply. And it must know the callback is real, because the endpoint is on the internet and a forged “delivered” would hide a failure. Providers sign their callbacks. Twilio, for example, sends an X-Twilio-Signature header computed with HMAC-SHA1 from the request and the account’s secret token (Twilio). The handler recomputes it and rejects anything that does not match.
Then comes the harder question: what did “delivered” mean? Each channel means something different by it.
For a text, Twilio’s “delivered” means the carrier confirmed delivery, and the handset too where that is available. Not every carrier reports it, so some texts stay “sent” forever without having failed. For email, Amazon SES reports a delivery when the recipient’s mail server accepted the message (Amazon SES). It may still land in spam, and a bounce or a complaint can arrive later. For push, Apple’s answer of 200 means only that Apple accepted it, and Apple sends nothing when the phone shows it. An email “open” is weaker still, because software can load the tracking image without a person. That is why SES marks each open with whether it was likely a bot.
So the status endpoint reports what each channel can honestly say, named for what it is: accepted by Apple, delivered to the handset, accepted by the mail server. The only channel where “she saw it” can be known is the one we own. The in-app inbox records when Isha opened the item.
Some receipts are instructions. A permanent email bounce means the address does not exist, so the sender stops using it. A spam complaint means the person does not want this mail, so the preferences service turns that category off for them. Both write back to the stores the sender checks, so the next campaign skips them without anyone deciding by hand. That protects the account as well: Amazon SES puts an account under review once its bounce rate reaches 5% or its complaint rate 0.1% (Amazon SES).
The experiment replays the four callbacks for Omar’s text. The tabs are overwriting one status column, and keeping each receipt while showing the furthest stage.
The interactive version of this example is available when JavaScript loads.
The gap: Providers report later, at least once and in any order, and each channel’s “delivered” means something different.
Option 1: Overwrite one status column
Each callback sets the delivery’s status.
Works when: A provider that reports once and in order, which Twilio, for one, does not promise.
Breaks when: A late callback moves a status backwards, and a repeated one is counted twice.
Option 2: Keep each receipt, and show the furthest stage (start here)
Store a receipt row keyed by delivery and stage, after checking its signature; the status is the furthest stage reached.
Works when: Always.
Watch for: “Delivered” means a different thing on each channel, so the status must say which.
In the interview: Open with option 2. Then say what “delivered” means for push, text and email, and that bounces and complaints feed back into the rules the sender checks.
Say this: Callbacks come at least once and in any order, so each is stored as its own row keyed by delivery and stage, after its signature is checked, and the status is the furthest stage reached. A repeat lands on the row it repeats, and a late one cannot move the status back. “Delivered” differs by channel: accepted by Apple for push, confirmed by the carrier for a text, accepted by the mail server for email. Bounces and complaints feed back into the rules.
If they push: a provider is down for ten minutes
Say the email provider fails every call for ten minutes. Senders see definite errors, and a circuit breaker stops them calling after a burst of failures, trying one call every few seconds to see if it has recovered. Meanwhile deliveries keep arriving. At 2,000 emails a second, ten minutes leaves a backlog of 1.2 million. When the provider returns, the backlog drains only at the capacity left over after new arrivals. With 3,000 a second allowed and 2,000 still arriving, 1,000 a second clears old work, so 1.2 million takes 1,200 seconds: twenty minutes. During those twenty minutes some deliveries pass their expiry and are dropped, which is right, because a sign-in email from half an hour ago is useless. Failing over to a second provider is safe for calls that failed definitely. Those that timed out stay unknown.
If they push: thirty likes in ten minutes
Isha lists a jacket for sale, and thirty people like it in ten minutes. Thirty pushes would teach her to turn pushes off, and that is the one outcome the system cannot undo. So some categories are grouped. The first like sends a push at once. Later likes within the hour go into a digest for Isha and that listing. One notification at the end of the hour says “Tom and 28 others liked your jacket”. The digest has its own key, built from Isha, the listing and the hour, so a retried digest is still one notification. LinkedIn reported that its notification controller, which handles over a billion requests a day, cut member complaints in half (LinkedIn).
If they push: templates and languages
A notification stores a template name with a version, parcel_ready@v4, and its parameters, never the finished words. The sender renders the template in the person’s language just before sending. Pinning the version means a retry says what the first attempt said, even if someone edits the template in between. An edit ships as v5, for new notifications only. Parameters are escaped for their channel, since a product name can contain characters that break an email or a link. A text is kept to one segment where the words allow: 160 characters in the standard SMS alphabet, and 70 once an emoji appears (Twilio).
Some parameters are secrets. A sign-in code must not sit in a notification row, a Kafka topic and a receipt for 30 days. So the notification stores the code encrypted, the store erases it once the code expires, and logs and receipts carry the delivery ID, never the rendered words.
If they ask: isn’t this just a message queue?
A message queue is one part of it: the lanes are Kafka topics. What the notification system adds is everything a queue does not know. It knows who a request is for, and turns one request into ten million deliveries. It knows each person’s rules and applies them at the last moment. It knows each provider’s limits and paces to them, what a timeout means, and what each provider’s callbacks say. A queue moves messages. This system decides whether each one should still be sent, and records what happened when it was. The message queue breakdown covers the queue itself.
Walk one notification through the final design
The parcel service calls POST /notifications with the key ev-88. The API inserts N1 and its outbox row in one transaction and replies 202. The relay publishes N1 to Kafka. A planner reads Isha’s preferences and finds push and the inbox for order updates. It writes d1 and d2 into the delivery log, with IDs built from N1, Isha and the channel. d1 goes to the push lane for order updates, and d2 to the inbox lane.
A push sender takes d1. It checks Isha’s preferences in Redis, her quiet hours and N1’s expiry. It takes a token from the push account’s bucket, records the attempt, and calls the push service for each of her tokens, with d1 as the collapse ID. The inbox sender writes d2 into her inbox, and her badge shows 1. When she opens the app, the inbox shows the parcel, and her read marker moves.
The interactive version of this example is available when JavaScript loads.
| Requirement | Where it is met | The trade-off |
|---|---|---|
| FR1 notify a person or an audience | Notification API and store, unique on caller and key; planners in pages of 1,000 | Callers must send a real key, and a campaign takes minutes to plan |
| FR2 push, text, email and inbox | Lanes per channel and priority, senders paced by one shared token bucket per account | The providers’ limits, not ours, set how fast anything leaves |
| FR3 opt-outs, quiet hours and caps | Checked by the sender just before each call, from Redis | One message already past its check can still arrive |
| FR4 send later, drop when useless | A scheduler for held deliveries, and an expiry on every notification | Callers must set honest expiries |
| FR5 status of each delivery | Attempts before each call; receipts kept by stage, the furthest wins | “Delivered” means something different on each channel |
How does the answer change for push notifications, email or alerts?
| Interview variant | What carries over | What changes |
|---|---|---|
| Design a push notification service | Lanes, pacing, tokens, the inbox as the record | Device tokens, APNs and FCM move to the centre, and collapse IDs make retries cheap |
| Design an email notification system | Keys, lanes, send-time checks, receipts | Bounces, complaints, sender reputation, separate transactional and marketing streams, one-click unsubscribe |
| Design Facebook or LinkedIn notifications | Everything on this page | Deciding which notifications to send at all, ranking and digests, becomes the main problem |
| Design a marketing campaign platform | Planning in pages, lanes, pacing, caps | Audiences, sending across time zones and reporting become the product |
| Design an alerting or paging system | Acceptance, lanes, receipts | Escalation: if nobody acknowledges within five minutes, page the next person |
| Design a chat system | Push through APNs and FCM, devices and tokens | Two-way conversation, ordering and catch-up. See the chat system breakdown |
What should an answer reach at each level?
| Level | What the answer shows |
|---|---|
| Intern or mid-level | Draws an API, a queue, workers per channel and the providers. Explains why the API replies before sending. Stores device tokens and preferences. |
| Senior | Makes acceptance safe to retry with a caller’s key. Plans campaigns in pages that can restart, with stable delivery IDs. Separates urgent and bulk lanes. Checks preferences, quiet hours and the expiry at send time. Removes dead tokens. |
| Staff | Treats a timeout as unknown and settles it from callbacks that carry the attempt ID, with a retry rule per channel. Paces every sender through one bucket per provider account with a reserve. Keeps receipts by stage and says what delivered means on each channel. |
| Principal | Chooses sender identities and reputation boundaries, what degrades first during an outage, how long to keep what, and what the product promises people about opt-outs and quiet hours. |
Test yourself with the quiz, then pick another problem from the System Design interview breakdowns.
By GOAT Engineer. Back to all breakdowns. Privacy Policy · Contact.