Send push, SMS and email to millions of users: queues, retries, preferences and no duplicates.
โDesign a notification system.โ
It is short on purpose. Your first job is to make it specific.
| What they check | Why it matters |
|---|---|
| Scoping a vague prompt | Push, SMS, email and in-app are different systems with different costs and guarantees. A strong candidate asks which channels, which kinds of message, and how many. |
| Reliability without duplicates | Nobody can promise exactly once. The interviewer wants at-least-once delivery plus an idempotency key, and an honest account of what happens when a send fails. |
| Isolation and priority | A marketing campaign must never delay a login code. This is the heart of the question and separates a diagram from a design. |
| Respecting outside limits | Providers such as APNs, FCM and SMS gateways have rate limits and outages. The design must pace itself and survive them. |
| Users and trust | Preferences, quiet hours, opt-out and not sending fifty pushes in a minute are product features that shape the data model. |
A notification system takes an event or a campaign and delivers it to the right user, on the right channel, once, at the right time. We build it as a pipeline: an intake API stores the request, a preference check filters it, separate priority queues feed one worker pool per channel, and the workers call the outside providers and record the result.
| Step | Minutes | What to get done |
|---|---|---|
| 1. Clarify | 4 | Channels, transactional vs marketing, scale, delivery promise, preferences. |
| 2. Estimate | 3 | Sends per second, per-channel mix, provider limits, token and log storage. |
| 3. API and data | 5 | One intake call with an idempotency key, preferences, the notification log. |
| 4. High-level design | 8 | Intake, checks, priority queues, channel workers, providers, status callbacks. |
| 5. Deep dives | 15 | Reliability and duplicates, then priority isolation, then preferences, then campaign fan-out. |
| 6. Scale and failures | 7 | Provider outage, hot campaign, dead tokens, monitoring, security. |
| 7. Wrap up | 3 | Recap, trade-offs, what you would do next. |
| Ask | Why you ask it | Typical answer | How it changes the design |
|---|---|---|---|
| Which channels: mobile push, SMS, email, in-app, or all of them? | Each channel has its own provider, cost, limits and delivery signal. | Push, SMS and email. In-app is a stretch goal. | One pipeline with a pluggable worker per channel, each with its own queue and rate limit. |
| What kinds of message: transactional (codes, receipts), event alerts, or marketing campaigns? | Urgent and bulk traffic cannot share a line, or a campaign will delay a login code. | All three. Codes must arrive in seconds. | Priority lanes with separate queues, workers and reserved provider capacity. |
| How many notifications a day, and how big can one campaign be? | Sets throughput, queue depth, and whether fan-out needs its own service. | About 10 million a day, bursts of 10 times, and campaigns up to 1 million recipients. | Modest throughput. A campaign expander with paging and pacing is required. |
| What does delivery guarantee mean: at most once, at least once, exactly once? | Decides retries, deduplication, and what we promise the business. | Never lose a code, and never send the same message twice if we can avoid it. | At-least-once queue plus an idempotency key. We say plainly that exactly once is not possible end to end. |
| Can users choose channels, opt out, or set quiet hours? | Preferences must be checked on every send and shape the data model. | Yes. Per channel and per category, with quiet hours by time zone. | A preferences store read on every notification, and time-zone-aware scheduling. |
| Do we need to know if it was delivered or opened? | Delivery receipts exist for some channels only and arrive later, if at all. | Track sent and delivered where the provider tells us, and clicks for email. | A status callback path and a notification log with a state machine. |
| Is a message built from a template, with languages and personalisation? | Rendering can be a separate service and affects message size and caching. | Yes, templates with variables, in several languages. | A template service, rendered at send time, versioned. |
| Can messages be scheduled for later, or sent at a local time? | Scheduling needs a timer store and affects fan-out timing. | Yes, such as 9 am in each user's time zone. | A scheduler that releases batches by time zone. |
| Do we own the providers or call third parties such as APNs, FCM and an SMS gateway? | Third parties set rate limits and fail on their own schedule. | Third parties, with a backup SMS vendor. | Pacing, retries, circuit breakers and provider failover. |
| How fast must a transactional message arrive? | The latency target decides how we protect that lane. | A login code within 5 seconds at the 99th percentile. | A short, dedicated path with a tight queue-age alert. |
| Assumption | Value |
|---|---|
| Notifications per day (average) | 10 million |
| Peak to average | 10 times |
| Channel mix | 70% push, 20% email, 5% SMS, 5% in-app |
| Largest campaign | 1 million recipients |
| Provider limit for one SMS or push account (illustrative) | about 1,000 sends per second |
| Share of that limit reserved for transactional traffic | 30% |
| Registered users and devices | 100 million users, 1.5 devices each |
| Notification log record | about 500 bytes, kept 90 days |
| One send call to a provider | about 100 ms, 50 in flight per worker |
| At-least-once redelivery rate (illustrative) | about 0.5% of messages |
| Price per SMS and per email (illustrative) | about $0.01 and $0.0001 |
| What | Maths | Result |
|---|---|---|
| Average sends per second | 10,000,000 รท 86,400 | about 116, say 120 per second |
| Peak sends per second | 120 ร 10 | about 1,200 per second |
| Push, email, SMS per day | 10M ร 70%, 20%, 5% | 7M push, 2M email, 500K SMS (and 500K in-app) |
| A 1M campaign at the full 1,000/s limit | 1,000,000 รท 1,000 | 1,000 s, about 17 minutes |
| A code stuck behind that campaign in one shared queue | up to the whole drain time | up to about 17 minutes (a code lives for about 5) |
| A campaign when 30% is reserved for codes | 1,000,000 รท (1,000 ร 70%) | 1,429 s, about 24 minutes |
| Send workers needed at peak | 1,200 รท (50 รท 0.1 s = 500 per worker) | 2.4, so 3. Run 6 for headroom and zones |
| Device-token table | 100M ร 1.5 ร 200 bytes | 30 GB |
| Preference table | 100M users ร 200 bytes | 20 GB |
| Notification log | 10M ร 500 bytes ร 90 days, then ร 3 copies | 5 GB a day, 450 GB, 1.35 TB replicated |
| Duplicates a day with no deduplication | 10,000,000 ร 0.5% | 50,000 people get a message twice |
| Daily cost of SMS versus email | 500K ร $0.01 against 2M ร $0.0001 | $5,000 against $200: 25 times the daily bill, from a quarter of the volume (100 times the price per message) |
| Method | Path | Request | Response | Notes |
|---|---|---|---|---|
| POST | /v1/notifications | { idempotencyKey, to: user | audience, template, data, priority, channels?, sendAt? } | 202 { id, status: queued } | Accepted, not delivered. The same idempotencyKey returns the same id and sends nothing new. Priority is transactional, alert or bulk. |
| GET | /v1/notifications/{id} | none | 200 { status, attempts: [{ channel, provider, state, at }] } | For support and the product team. Reads the log, never changes it. |
| PUT | /v1/users/{id}/preferences | { channels: { push, sms, email }, categories, quietHours: { start, end, zone } } | 200 | Read on every send, so it is cached. An opt-out takes effect within seconds. |
| POST | /v1/devices | { userId, platform, pushToken } | 201 | Called by the app on start-up. A token can change or die, so this is an upsert. |
| POST | /v1/campaigns/{id}/pause | none | 200 | Also resume and cancel. Campaigns are long-running jobs with a state, not a single request. |
| POST | /webhooks/{provider} | provider payload | 200 | Delivery receipts and bounces from outside. Verify the signature, then update the log. Must be idempotent. |
| Table | Key fields | Notes |
|---|---|---|
| notifications | id, idempotency_key (unique), user_id, template, priority, state, created_at, send_at | The source of truth. State machine: queued, rendering, sent, delivered, failed, suppressed. |
| attempts | notification_id, channel, provider, state, error, at | One row per try. Explains why a message was or was not sent. |
| user_preferences | user_id, channel opt-ins, categories, quiet_hours, time_zone | About 20 GB. Cached in memory, written through on change. |
| devices | user_id, platform, push_token, last_seen | About 30 GB. A dead token is deleted when a provider reports it invalid. |
| templates | id, version, locale, channel, body | Versioned, so a send always uses the version it was queued with. |
| campaigns | id, audience_query, state, cursor, total, sent | The cursor lets a crashed campaign resume where it stopped. |
{
"notificationId": "n_8f21",
"idempotencyKey": "order-991-shipped:u_42:push",
"userId": "u_42",
"channel": "push",
"priority": "transactional",
"template": { "id": "order_shipped", "version": 7, "locale": "en" },
"data": { "orderId": "991" },
"attempt": 1
}| Component | What it does |
|---|---|
| Intake API | Validates, checks the idempotency key, saves the notification, and answers 202. It does no sending. |
| Log and outbox | The notification row and the queue message are written in one local transaction, so we never save without queueing, or queue without saving. |
| Router | Reads preferences (cached), applies opt-out, quiet hours and frequency caps, picks channels, and puts a message on the right lane. |
| Priority lanes | Separate queues (and worker pools) for transactional, alert and bulk traffic. Transactional has reserved capacity. |
| Channel workers | Render the template, call the provider with a pacing limit and a timeout, and record the attempt. Retries with backoff and jitter. |
| Provider layer | Wraps APNs, FCM, SMS and email vendors. Has a circuit breaker per provider and a backup vendor for SMS. |
| Campaign expander | Turns an audience into batches, pages through it, checkpoints a cursor, and feeds the bulk lane at a paced rate. |
| Scheduler | Holds messages with a send time and releases them on time, including local times by zone. |
| Webhook receiver | Takes receipts and bounces from providers, verifies them, and updates the log. Removes dead tokens and suppresses bounced addresses. |
The problem: A send can fail at any step: the server crashes after saving, the worker crashes after calling the provider but before acknowledging, the provider times out after actually sending. We must not lose a notification, and we must not send it twice. Both cannot be guaranteed perfectly, so we choose which error to prefer.
| Option | How it works | Good | Bad |
|---|---|---|---|
| Send in the request, no queue | The intake API calls the provider and returns the result. | Simplest. Immediate feedback. | A slow provider slows the caller. A crash loses the message. No retries. |
| Queue only (at-most-once) | Publish to a queue and acknowledge before sending. | No duplicates. | A crash after the acknowledgement loses the message. Wrong for a login code. |
| Outbox plus at-least-once queue plus idempotency key | Save the notification and an outbox row in one transaction. Publish from the outbox. Workers acknowledge after sending, and skip a key they already sent. | Nothing is lost. A repeat is recognised and skipped. Retries are safe. | More parts. A small window remains: a provider that accepted a send but did not answer may send twice. |
| Exactly-once from the broker | Rely on transactional features of the queue. | Fewer duplicates inside the queue. | Stops at the edge: the call to an outside provider is not part of that transaction. Not a real guarantee here. |
Save before you queue. The notification row and the outbox row are written in one local transaction, so the intake API can crash at any point and nothing is lost or half-saved. A relay publishes from the outbox, possibly more than once, which is fine because the next steps are idempotent.
Prefer a duplicate to a loss for a code, and say so. Workers acknowledge after the provider call. If a worker dies in between, the message is redelivered. The idempotency key (a unique key in a fast store, set before the call and confirmed after) makes the second attempt a no-op. For providers that accept a client-supplied message id (many email and SMS vendors do), pass the same id so they de-duplicate too.
msg = queue.take()
key = msg.idempotencyKey // "order-991-shipped:u_42:push"
if store.alreadySent(key): ack(msg); return // a repeat: do nothing
if !pacer.tryAcquire(msg.provider): // respect the provider limit
requeue(msg, delay = backoff(msg.attempt)); return
result = provider.send(msg, clientId = key, timeout = 2s)
if result.ok:
store.markSent(key); log.sent(msg); ack(msg)
else if result.temporary: // 5xx, timeout, throttled
requeue(msg, delay = backoff(msg.attempt) + jitter)
else: // permanent: bad token, bounced address
log.failed(msg); cleanup(msg); ack(msg)
after max attempts: deadLetterQueue.put(msg); ack(msg)| Where it fails | What the system does |
|---|---|
| Intake crashes before saving | Nothing was accepted. The caller sees an error and retries with the same key. |
| Crash after saving, before queueing | The outbox row is still there. The relay publishes it on restart. |
| Worker crashes after the provider accepted | The message is redelivered. The key (and the provider's own id) stops a second send in most cases. |
| Provider times out after sending | The one case that can duplicate. We accept it and say so: duplicate over loss. |
| Provider rejects the token or address | A permanent failure: do not retry. Delete the token or suppress the address. |
The problem: All traffic wants the same provider capacity. A million-message campaign can fill a shared queue for 17 minutes. A login code that arrives behind it expires before it is sent. We also have per-provider rate limits we must not exceed.
| Option | How it works | Good | Bad |
|---|---|---|---|
| One shared queue, first in first out | Everything goes into one line. | Simplest. Fair by arrival. | A campaign blocks everything behind it. The failure we are trying to avoid. |
| One queue with priority levels | A priority queue serves urgent messages first. | One system. Urgent jumps ahead. | A busy bulk worker pool still holds the provider connections. Starvation of bulk. Hard to reason about under load. |
| Separate queues and worker pools per priority and channel | Transactional, alerts and bulk each have their own queue, workers and autoscaling. | Real isolation. A bulk backlog cannot touch urgent traffic. Easy to alarm per lane. | More queues to run. Idle capacity in the quiet lane. |
| Separate lanes plus reserved provider capacity | As above, and a per-provider token bucket gives transactional a guaranteed share (for example 30%) that bulk cannot spend. | Isolation holds even at the provider limit. Bulk is paced to the leftover. | Bulk is slower than it could be. Needs the provider limit to be known. |
Isolation has to hold at three places: the queue (so a backlog cannot block), the workers (so bulk cannot use up the connections), and the provider limit (so bulk cannot spend the allowance). That is why a priority queue alone is not enough. Each channel and priority has its own queue and pool, and each provider has a token bucket per lane, with transactional guaranteed its share.
Bulk is allowed to be slow: with 30% reserved, our million-message campaign takes about 24 minutes instead of 17, and that is the right thing to give up. Alarm on queue age in the transactional lane (oldest message above a few seconds), not on queue length.
| Lane | Queue | Workers | Provider share | Alarm |
|---|---|---|---|---|
| Transactional | own, short | own pool, always warm | 30% reserved, can borrow | oldest message above 5 s |
| Alerts | own | own pool | shares the rest | oldest above 60 s |
| Bulk | own, deep | small pool, scales on a schedule | what is left, paced | campaign behind its plan |
The problem: A notification system that sends everything it is asked to will get uninstalled, blocked or reported as spam. We must honour opt-outs and quiet hours, cap how often one person is contacted, and merge noisy events, all on every send and without slowing the pipeline.
| Option | How it works | Good | Bad |
|---|---|---|---|
| Callers decide | Each product team checks preferences before calling us. | Simple for the platform. | Every team reimplements it, differently. Opt-outs get missed. Legally risky. |
| Central check at send time | The router reads preferences, quiet hours and caps for each message. | One place, always applied. An opt-out takes effect at once. | A read on every send, so it needs a cache. Adds a little latency. |
| Central check at send time, plus digest and collapse | As above, and batch similar events (50 likes) into one message, or replace an older unread one with the newer. | Fewer, better notifications. Less SMS spend. | A delay for digest items. More logic and state. |
The platform owns this, because it is the only place that sees everything sent to a person. The router reads the user's preferences from a cache (about 20 GB, so it fits in memory across a few nodes), drops opted-out channels, and holds back anything inside the user's quiet hours. Transactional messages such as a login code are normally exempt from quiet hours and from marketing opt-out, and that exemption is a rule the business must own.
For frequency, a counter per (user, category) in Redis allows, say, 3 marketing messages a day. For noisy event streams, a collapse key keeps only the latest notification of a kind, and a short digest window merges many into one. Quiet hours and scheduled sends need the user's time zone, so the scheduler releases a campaign in waves by zone, not all at once.
| Rule | Applies to | Where it runs |
|---|---|---|
| Opt-out by channel or category | Marketing and alerts. Not legal or security messages. | Router, from the preference cache |
| Quiet hours (user time zone) | Marketing and alerts. Codes are exempt. | Router holds the message and the scheduler releases it |
| Frequency cap (for example 3 a day) | Marketing | Counter in Redis per user and category |
| Collapse key | Event streams (likes, comments) | Keep the newest, drop older unsent ones |
| Digest window | Low-urgency events | Hold for a few minutes, then send one summary |
| Channel fallback order | Everything | Push first, then email, SMS only when it matters (it costs the most) |
The problem: A campaign is one request that means a million sends. Creating a million messages at once floods the queue and the database, a crash halfway can send some people twice or never finish, and an operator who spots a typo needs to stop it now.
| Option | How it works | Good | Bad |
|---|---|---|---|
| Create all messages up front | Query the audience and enqueue one message per person immediately. | Simple. | A huge memory and queue spike. Cannot be paused. A crash loses track of who was done. |
| One worker loops over the audience | A single job pages through users and sends. | Easy to follow. Easy to pace. | One machine is the limit. A crash restarts from the beginning. |
| Paged expansion with a checkpoint cursor | The expander reads the audience in pages (for example 1,000 ids), enqueues them to the bulk lane, and saves the cursor after each page. | Resumable. Memory stays small. Paced. Can pause and cancel between pages. | More state to keep. Audience can change while it runs, so fix the audience at the start. |
| Sharded expansion | Split the audience by id range or user hash across several expanders, each with its own cursor. | Scales to very large audiences. Faster. | More coordination. Pacing must be shared across shards. |
Fix the audience when the campaign starts (a snapshot or a stable query), so people do not move in and out. The expander walks it in pages, enqueues each page to the bulk lane, and saves a cursor after every page. After a crash it resumes from the cursor, and the idempotency key (campaign id, user, channel) makes the one possibly-repeated page harmless.
Pace the ramp-up: start slowly, watch error rate and provider throttling, and grow. Keep a progress record (total, enqueued, sent, failed, suppressed) so an operator can watch it, and check a paused or cancelled flag before each page. Pause and cancel stop new pages at once, and the workers drop queued messages for a cancelled campaign.
| Campaign state | What happens |
|---|---|
| Draft, then scheduled | Audience query and template are saved. Nothing is sent. A send time is set. |
| Running | The expander pages through the audience, saves its cursor, and feeds the bulk lane at the paced rate. |
| Paused | No new pages. Queued messages for it are skipped by workers. Resume continues from the cursor. |
| Cancelled | No new pages. Workers drop its queued messages. The record keeps the counts. |
| Done | Cursor at the end, and the sent, failed and suppressed counts add up to the audience. |
A simplified model with fixed numbers (no random values). The provider sends up to the limit each second. Workers retry by pausing during the outage, which is what backoff achieves. Redeliveries are set at 0.5% of sends, an illustrative rate for an at-least-once queue.
| Bottleneck | Fix |
|---|---|
| Provider rate limits (not our hardware) | A token bucket per provider and lane, with transactional reserved. Ask for higher limits, and add providers or accounts before adding workers. |
| Bulk backlog after a big campaign | Separate bulk lane, paced ramp-up, and scale bulk workers on a schedule. Never let it share workers with transactional. |
| Preference and token lookups on every send | Cache in memory (about 50 GB in all), write-through on change, and batch lookups per page for campaigns. |
| Hot database rows (a popular user, a busy campaign counter) | Shard the log by user id, and count campaign progress in batches or in Redis, then flush. |
| The notification log grows without limit | Partition by day, keep 90 days hot, archive the rest to cheap storage, and drop payloads sooner than metadata. |
| Template rendering cost at 1M a campaign | Render at send time from a cached, compiled template. Pre-render only if the body is identical for all. |
| Time-zone peaks (everyone at 9 am) | Release the scheduled sends in waves by zone, which also spreads provider load across the day. |
| Failure | How the design copes |
|---|---|
| A provider is down or throttling | Circuit breaker per provider. Retry with backoff and jitter, then fail over to a backup vendor for SMS and email. Urgent traffic gets the backup first. |
| Worker crashes mid-send | The message is redelivered. The idempotency key stops a second send in nearly every case. |
| A queue or broker node fails | Replicated queues. Producers retry. The outbox means nothing accepted is lost. |
| A dead or invalid device token | The provider says so. Delete the token on a permanent error and do not retry. |
| A bad campaign (wrong template, wrong audience) | Pause or cancel within a page, workers drop its queued messages. Test sends and a small first wave catch most of these. |
| Webhook receipts are late or missing | Treat sent as the main state and delivered as bonus. A timeout turns an unknown into 'sent, not confirmed' without a retry. |
An intake API saves each request with an outbox row in one transaction and answers 202. A router applies preferences, quiet hours and caps, and puts work on separate lanes for transactional, alert and bulk traffic, each with its own queue and workers and a share of every provider's limit. Workers send with an idempotency key, retry with backoff, and dead-letter what keeps failing. Campaigns expand in pages with a checkpoint and can be paused. Webhooks close the loop and clean up dead tokens.
| Decision | What we gain | What it costs |
|---|---|---|
| At-least-once with an idempotency key | Nothing accepted is lost, and duplicates are almost always caught. | A rare duplicate when a provider sends but times out. True exactly-once is not possible. |
| Separate lanes with reserved provider capacity | A campaign can never delay a login code. | More queues and pools to run, and bulk is slower than it could be. |
| Central preference check at send time | Opt-outs and quiet hours are applied everywhere, at once. | A cached read on every send, and one more component to keep available. |
| Outbox before the queue | No lost or half-saved notifications. | A relay to run and a small publish delay. |
| Sent as the main state, delivered as a bonus | Honest about what we know. Works for every channel. | Product teams must accept that delivery receipts are partial. |
| Digest and collapse for noisy events | Fewer messages, happier users, lower SMS cost. | Some updates arrive a few minutes late. |
The interviewer wants to hear you refuse to promise exactly once, and still show a design that behaves like it.
The traffic is easy. The shared resource is the provider limit.
These questions test whether you think about the person at the other end.
These change the problem. Say what changes and what stays.
A change in requirements is a test of whether you understand why your design looks the way it does.
| New requirement | What changes in the design |
|---|---|
| Add real-time in-app notifications | A new channel worker writes to a per-user inbox and pushes through a connection service. The inbox is the source of truth. The router, preferences and log are unchanged. |
| Messages must arrive in order for a user | Partition by user id so one user's messages go to one worker, add a sequence number the client checks, and accept lower parallelism. Prefer a collapse key where only the latest matters. |
| Strict regional rules: data must stay in the EU | A full stack per region, users homed to a region, providers chosen per region, and logs that never leave it. Cross-region campaigns run one expander per region. |
| Users can reply to a message | Add an inbound path: provider webhooks for replies, a parser, and routing to the right team. Add spam checks. This is a new system beside the sender. |
| Guaranteed delivery with an audit for the regulator | Stronger log retention, an immutable audit trail, delivery confirmation as a requirement, and a fallback to a second channel when no receipt arrives. |
| Cost cap: SMS budget is cut by 80% | Move to push and email first, use SMS only for codes, add per-team quotas and digests, and report spend by team. A routing rule, not new architecture. |
| Notifications triggered by thousands of events a second per user (a trading app) | Collapse keys and digests become mandatory, with a per-user rate limit and a local aggregator. The queue sees fewer, merged messages. |
| Very low latency for codes: under 1 second | A dedicated, always-warm transactional path with local provider connections, a short timeout, an immediate second provider, and no preference lookup beyond a cache hit. |
| Area | Weak | Good | Great |
|---|---|---|---|
| Requirements | Starts with queues. Never separates urgent from bulk, or asks about channels and guarantees. | Asks about channels, scale, urgency and delivery promise, and writes them down. | Also asks about preferences, quiet hours, receipts and cost, and states what is out of scope. |
| Estimation | No numbers, or assumes the hard part is throughput. | Sends per second, a peak, and storage. | Notices that a campaign drains for minutes at the provider limit, and uses that to justify separate lanes. |
| Reliability | Says use a queue with exactly once. | Outbox or retry with an idempotency key, and a dead-letter queue. | Explains the acknowledge-after-send gap, the provider-timeout duplicate, and chooses duplicate over loss for codes. |
| Isolation and limits | One shared queue, or a priority field only. | Separate queues per priority. | Isolates queue, workers and provider share, paces with a token bucket, and alarms on queue age. |
| User respect | Sends whatever it is told. | Checks preferences and opt-outs. | Quiet hours by zone, frequency caps, collapse and digest, and exempts codes by rule. |
| Communication | Draws a box for every vendor without a reason. | Follows the steps and explains choices. | Names what is approximate or not guaranteed, summarises each step, and checks in with the interviewer. |
| Mistake | Do this instead |
|---|---|
| Promising exactly-once delivery | Say at-least-once plus deduplication, and name the one gap: the provider that sent but timed out. |
| One shared queue for everything | Separate lanes, workers and a reserved share of each provider limit, and alarm on the oldest transactional message. |
| Calling the provider inside the request | Accept, save with an outbox row, return 202, and send from workers. |
| Retrying everything immediately | Retry only temporary failures, with backoff and jitter, a maximum attempts and age, and a dead-letter queue. |
| Ignoring the provider's rate limit | Pace with a token bucket per provider and scale on the allowance, not on CPU. |
| Letting every team check preferences themselves | Check centrally in the router, at send time, so opt-outs are applied everywhere. |
| Putting personal data in queue messages and logs | Carry ids, fetch details at send time, and keep sensitive details out of push and SMS bodies. |
| Treating delivered as always known | Use sent as the main state, delivered as a bonus where receipts exist, and say so to product teams. |
How a message reaches a closed phone through APNs and FCM.
The lanes between the router and the workers.
Where the messages that keep failing go.
Retrying temporary failures without causing a flood.
How a repeated message is recognised and skipped.
Saving the request and the queue message together.
Pacing sends to a provider's limit.
How providers report receipts and bounces back to you.
The token bucket that paces each provider lane.