Many services, three channels, unreliable third party providers. The design is about keeping channels isolated from each other, retrying without spamming, and respecting what each user asked for.
Requirements. Send push, SMS and email for every team in the company, from templates, now or on a schedule; respect each user’s preferences and quiet hours; login codes arrive within seconds; nothing is lost and nothing arrives twice.
Daily volume
16M per dayabout 185 per second
Campaign peak
17,000 per second10M pushes in 10 minutes
Log storage
2.9 TB a year16M rows of 500 B a day
The design. Services call one API with an event ID. The notification row is written first, with a unique event ID so a repeated event is dropped, then queued on its channel’s own queue, with a fast lane for login codes and payment alerts. Workers check the user’s preferences at send time, call the provider within its rate limit, retry with backoff and jitter, and move repeated failures to a dead letter queue. Provider callbacks and app opens update the status.
Interview prompt
Design a system that sends push notifications, SMS and email on behalf of every team in the company.
Requirements and estimates
Functional requirements
Send through push (iOS, Android), SMS and email.
Respect per user preferences, opt-outs and quiet hours.
Immediate, scheduled and bulk campaign sends from templates.
Track sent, delivered and opened.
Non-functional requirements
Urgent messages such as login codes arrive within seconds.
No lost notifications, and no duplicates the user can see.
A slow provider in one channel never delays the others.
Estimates
Daily volume 10M push + 1M SMS + 5M email = 16M per day, ≈ 185/s
Campaign peak 10M pushes in 10 minutes ≈ 17,000/sLog storage 16M × 500 B × 365 days ≈ 2.9 TB per year
What you sketch in the first five minutes: the lanes that keep the channels apart, then the path of one message that fails.
1. One queue per channel
Say: a slow SMS provider must never delay a push, and a campaign must never delay a login code.
Services send one request with an event ID, and the row is written before anything is queued.
Each channel gets its own queue, and each queue a fast lane for login codes.
Workers call each provider within its rate limit, so a 10M campaign drains at its own pace.
Next question: how does a campaign reach 10M users without breaking anything? Expand the audience in batches into the slow lane.
2. Retry without sending twice
Say: retries make delivery reliable; the unique event ID makes them safe.
The same event published twice hits the unique event_id and is dropped.
A failed send retries with exponential backoff and jitter.
After the last attempt it moves to a dead letter queue, and someone is alerted.
Next question: a worker crashes after sending but before marking it sent. The app ignores notification IDs it has already shown.
Delivery you can trust
Persist first. Write the notification row, then enqueue it. If a worker crashes, a sweeper finds rows stuck in PENDING and re-enqueues them.
Deduplicate by event ID. The unique constraint on event_id means a service that publishes the same event twice still produces one notification.
One queue per channel, with priority lanes. Login codes and payment alerts never wait behind a ten million user marketing campaign.
Retry with exponential backoff and jitter, within each provider’s rate limits. After a fixed number of attempts, move the message to a dead letter queue and alert.
Close the loop. Providers report delivery through callbacks; the app reports opens. Both update the status row.
Channel
Provider examples
Watch out for
Push
APNs (Apple), FCM (Google)
Device tokens go stale. Delete a token when the provider reports the app as unregistered.
SMS
Twilio, Vonage
Cost per message, country specific sender rules, and abuse such as SMS pumping fraud.
Email
Amazon SES, SendGrid
Bounces and spam complaints damage your sender reputation. Marketing email needs an unsubscribe link.
Not annoying people
Check preferences at send time, not when the message is queued, because a user may opt out in between. Cap marketing messages per user per day, hold non-urgent messages during quiet hours in the user’s own time zone, and bundle bursts into digests: “12 people liked your post” instead of twelve pings.
What the interviewer probes next
How do you send a campaign to 10M users without breaking anything?
A scheduler expands the audience in batches of a few thousand and feeds the low priority lane. Workers throttle to each provider’s quota. Transactional messages use their own lane and workers, so they are unaffected.
A login code must arrive fast. How?
A dedicated high priority queue with reserved workers, a short expiry (a code that arrives after it expires is useless), and a fallback from push to SMS if no delivery receipt arrives within a few seconds.
The same event is published twice. Does the user get two pushes?
No. The second insert violates the unique event_id and is dropped. As a second guard, the app ignores notification IDs it has already shown.
How do you know a notification was opened?
The app reports opens with the notification ID; emails use a tracking pixel and wrapped links. Events stream into analytics and update the status row.