Case study V.4Intermediate

Design a Notification System

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.

The short answer

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/s
Log storage   16M × 500 B × 365 days             ≈ 2.9 TB per year

API and data model

API

POST /v1/notifications
{ "eventId": "evt_8812", "userId": 42,
  "template": "payment_succeeded",
  "params": { "amount": "€50" },
  "channels": ["push", "email"],
  "priority": "high" }
→ 202 Accepted { "notificationId": "ntf_19a" }

Data model

devices        user_id, token, platform
preferences    user_id, category, channel,
               enabled, quiet_hours
notifications  id PK, event_id UNIQUE,
               user_id, channel, status,
               sent_at, opened_at

Whiteboard

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.

orange: login codesblue: campaignsservicesAPIrowswritten firstpushAPNs, FCMSMSTwilioemailSESslow todayonly SMS backs up; push and email keep going
  1. Services send one request with an event ID, and the row is written before anything is queued.
  2. Each channel gets its own queue, and each queue a fast lane for login codes.
  3. 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.

evt_8812evt_8812published twiceevent_idUNIQUEone rowone pushtry 1try 2try 3waitlongerdead letterand an alertbackoff doubles the wait, plus random jitter
  1. The same event published twice hits the unique event_id and is dropped.
  2. A failed send retries with exponential backoff and jitter.
  3. 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.
ChannelProvider examplesWatch out for
PushAPNs (Apple), FCM (Google)Device tokens go stale. Delete a token when the provider reports the app as unregistered.
SMSTwilio, VonageCost per message, country specific sender rules, and abuse such as SMS pumping fraud.
EmailAmazon SES, SendGridBounces 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.

Building blocks used here

Want to run this as a mock interview? See interview prep.

© 2026 Arman Ajabkhani · armantik.com · Privacy