Asked at
URL Shortener (TinyURL)
Asked from Junior level upFoundations & Storage
Distributed Rate Limiter
Asked from Mid level upAPI Gateway & Security
Distributed Key-Value Store
Asked from Senior level upFoundations & Storage
Distributed Notification Service
Asked from Mid level upMessaging & Queues
Distributed Web Crawler
Asked from Mid level upDistributed Systems
Metrics & Monitoring Platform
Asked from Senior level upObservability & Time-Series
Real-Time Chat App (like WhatsApp or Slack)
Asked from Mid level upReal-Time & WebSockets
Social News Feed (like X/Twitter)
Asked from Mid level upSocial & Feed Systems
Ride-Hailing App (like Uber)
Asked from Senior level upGeospatial & Real-Time
Low-Latency Stock Exchange Matching Engine
Asked from Staff level upFintech & Low Latency
Global Video Streaming Platform (like YouTube or Netflix)
Asked from Senior level upMedia & Streaming
Distributed Hotel & Ticket Reservation System
Asked from Mid level upE-Commerce & Transactions
Shared Document Editor (like Google Docs)
Asked from Staff level upReal-Time & Distributed State
Game Leaderboard
Asked from Junior level upCaching & Data Structures
File Sync Service (Dropbox / Google Drive)
Asked from Mid level upStorage
Payment System
Asked from Senior level upPayments & Transactions
Ad Click Aggregation
Asked from Senior level upStream Processing
AI Support Assistant (RAG)
Asked from Senior level upAI Systems
LLM Inference Platform
Asked from Senior level upAI Systems
Enterprise Semantic Search
Asked from Mid level upAI Systems
AI Code Completion
Asked from Senior level upAI Systems
LLM Gateway
Asked from Senior level upAI Systems
AI Agent That Takes Actions
Asked from Senior level upAI Systems
LLM Evaluation Platform
Asked from Senior level upAI Systems
AI Document Processing Pipeline
Asked from Mid level upAI Systems

Design a Distributed Notification Service

Asked from Mid level upDomain: Messaging & Queues
Concepts to know first:

Design a service that sends push messages, text messages and emails, at very large scale, without losing any.

An analogy

Think of a notification service like a central post office. It takes one announcement and fans it out across several couriers: Push, SMS trucks, and Email carriers. Users get alerted on whichever device they use.

Where this design ends up. This is version 3 of 3. Part 5 builds it up from version 1 and says why each part was added.
  1. Clients
    • Your service
  2. Entry
    • API gateway
  3. Services
    • Notification service
    • Channel workers
  4. Queues, caches
    • Message queues
    • Dead letter queue
  5. Data, outside
    • Preferences database
    • Providers

1. Requirements and scope

Functional Requirements
  • Deliver push notifications (iOS APNS, Android FCM), SMS (Twilio), and Emails (SendGrid).
  • Support user notification preferences and opt-outs.
  • Provide delivery status tracking and retries.
Non-Functional Requirements & SLAs
  • Guaranteed at-least-once delivery.
  • Low latency for transactional alerts (<5s).
  • Prioritization (OTP alerts bypass promotional blasts).
Key Traffic Assumptions: 10 million notifications a day, with peaks of 5,000 a second during a campaign.

2. Back-of-the-envelope numbers

Writes and reads each second
  • Writes: 120 notifications a second, on average (6%)
  • Reads: 2,000 status checks a second (94%)

Read-heavy: about 17 reads for each write. A cache and extra read copies help most here.

Write Throughput
~120 QPS avg (10M/day ÷ 86,400), 5,000 QPS peak during campaigns
Read Throughput
2,000 QPS status polling
Storage Growth
10M/day × 500 bytes × 365 = ~1.8 TB / year
RAM Cache Footprint
Redis for the deduplication keys: at most about 3 million at once (5,000 a second × a 10-minute TTL), well under 1 GB

3. API

POST/api/v1/notifications/sendSend notification: { recipientId, channels, priority, templateId, params }
GET/api/v1/notifications/{id}/statusQuery delivery receipt

4. Data model and storage

Storage Strategy: PostgreSQL holds message templates and user settings. Cassandra holds the log of every message sent, because that log takes many writes.
NOTIFICATION_LOG: (id, user_id, channel, status, retry_count, created_at, delivered_at)

5. The design, in three versions

Version 1: Synchronous Direct Dispatcher

The app server calls the sending companies, such as Twilio and SendGrid, and waits for each answer.

Distributed Notification Service: Version 1: Synchronous Direct Dispatcher Version 1 of 3

The picture follows one request through the parts of this version, in order. Under it, switch a part off to see what the request does without it.

One request, step by step

Each numbered arrow is one step. Press "Simulate Request Flow" to follow them one at a time.

Your serviceNotification serviceProviders123
  • The order of the steps
  • A request or its reply

The parts: switch one off

1. Clients

Your servicewants to notify a user

2. Services

Notification servicebuilds the message

3. Data, outside

ProvidersAPNs, SMS, email

The steps in words0 of 3 steps shown

  1. Your service to Notification serviceHTTPS · 3 ms

    A service asks to notify user 42.

  2. Notification service to Providersoutside call · 80 ms

    The app calls the provider and waits for it.

  3. Notification service to Your servicereply · 20 ms

    It answers only after the provider replies.

Why this version
Fast initial deployment.
Next bottleneck
Slow vendor response times block server threads. Failures lose messages.

Write path, read path and failures

Each path follows one request through the final design (version 3), one hop at a time.

Write pathSend a notification

  1. Your service
  2. Gateway
  3. Kafka topic
  4. Preference evaluator
  5. Dispatch workers
  6. Provider
  7. Event log
  1. Your service to Gateway

    A service calls POST /api/v1/notifications/send for user 42, with a template and an idempotency key.

  2. Gateway to Kafka topic

    The gateway checks the caller and writes the request to Kafka, grouped by user id. It answers "accepted" at once.

  3. Kafka topic to Preference evaluator

    A worker reads the message and checks what user 42 allows. A marketing message to a user who opted out is dropped here.

  4. Preference evaluator to Dispatch workers

    The message goes to the worker pool for its channel: push, SMS or email.

  5. Dispatch workers to Provider

    A worker checks the idempotency key, then calls the provider. A token bucket keeps it under the provider's rate limit.

  6. Dispatch workers to Event log

    The worker records the result: sent, failed or retrying.

Read pathCheck the delivery status

  1. Your service
  2. Gateway
  3. Notification API
  4. Event log
  1. Your service to Gateway

    The caller sends GET /api/v1/notifications/{id}/status.

  2. Gateway to Notification API

    The gateway checks the caller and passes the request on.

  3. Notification API to Event log

    The API reads the latest status for that id from the event log.

  4. Notification API to Your service

    It returns the status, such as "delivered at 12:00:05".

What breaks, and what happens then

  • A provider, such as the SMS vendor, is down

    What users see
    Messages on that channel are late. Other channels are not affected.
    What the design does
    Workers retry with growing waits. After several failures the message moves to the dead letter queue for review.
  • A worker crashes after calling the provider but before recording it

    What users see
    Kafka delivers the message again to another worker.
    What the design does
    The idempotency key is already stored, so the second worker skips the send. The user gets one message.
  • A marketing campaign floods the queue

    What users see
    Login codes could wait behind millions of promotions.
    What the design does
    Urgent and normal messages use separate topics and workers, so codes never queue behind campaigns.

6. Deep dives

Idempotent Delivery & Deduplication
Vendors and networks can drop acknowledgments causing retries. So a code could go out twice. To avoid that, make a fixed idempotency key: a hash of userId, templateId and timestamp bucket. Store it in Redis with SETNX and a 10-minute TTL.

7. Follow-up questions

  • How do you handle users who opt out of marketing but must receive security OTPs? (Answer: Strict separation of Transactional vs Promotional pipelines with separate priority queues).

What it costs

The provider fees are the largest part: each text message costs money, while push messages are free to send. Your own servers are small next to that. Send by push first, and use a text only when the message is urgent.

Another way to design it

At low volume, a job table in your database and a few workers can replace Kafka. It is one less system to run. It stops being enough when a campaign sends millions of messages in minutes.

8. How answers are judged

A passing answer at Mid level. A complete design with numbers: about 120 notifications a second on average, bursting to 5,000 at peak during a campaign. It explains at-least-once delivery and goes deep on one part, such as duplicate sends.

How each level is judged
What is judgedJuniorMidSeniorStaff
BreadthHow much of the system does the answer cover?Names the core parts: clients, servers, a database and a cache.Covers the whole main flow, from the request to the stored data and back.Builds a complete design without being led through it.Covers the system, the systems around it and who owns each part.
DepthHow far does it go into the hard parts?Explains what each part does and why it is there.Goes deep on one part, such as the database or the cache.Goes deep on the two or three riskiest parts.Goes deepest where the risk is largest, and explains why the risk is there.
DrivingWho leads the conversation?Follows the interviewer, step by step.Moves forward alone, with an occasional nudge.Leads the conversation from start to finish.Changes the problem when the question asked is not the right one.
Trade-offsAre choices compared and justified?Names more than one option.Says why one option was picked over another.Compares options in detail, with what each one costs.Ties each choice to cost, speed and risk for the business.
Unclear questionsWhat happens when the question is vague?Answers the questions that are asked.Asks questions to make the problem clear.Sets the scope and says what is left out.Questions the assumptions behind the problem itself.
ScopeWhat does it consider beyond the normal path?Covers the normal path, when everything works.Adds what happens when a part fails.Adds growth: what breaks at ten times the load, and the fix.Adds abuse, cost and the daily work of running the system.

Requirements and scope

Strong answer
Before I design, I want to check the scope. Notifications go out over push, SMS and email, and users can opt out. Should a security code bypass a promotional blast queue? I will assume at-least-once delivery, and that transactional alerts must arrive in under 5 seconds.
Weak answer
Users get notified over push, SMS or email depending on their device. Every notification goes out through the same pipeline, in the order it was sent.

Shows: Unclear questionsThe difference: Treating a security code the same as a promotional blast can delay it behind bulk sends. The strong answer asks about that split before designing.

Estimates

Strong answer
10 million notifications a day is about 116 a second on average, which I would round to about 120. Campaigns burst to the stated peak of 5,000 a second, about 40 times the average, so the write path needs a queue to absorb it. At 500 bytes each, a year of logs is about 1.8 TB.
Weak answer
10 million notifications a day at 500 bytes each is about 5 GB. Storage is small, so one server will hold it for a long time.

Shows: DepthThe difference: Five GB covers one day only; the weak answer never multiplies by the year the service runs, which comes to about 1.8 TB.

Core design

Strong answer
Templates and preferences sit in Postgres, since they change rarely and are looked up by user. The delivery log is only written and read by notification ID, and it grows by about 1.8 TB a year. So it gets its own store keyed by that ID, dropping rows after, say, 90 days: Cassandra with a time-to-live, or monthly Postgres partitions.
Weak answer
I would store every notification attempt as a row in one Postgres table, with an index on user ID. I would keep every row for good as delivery history.

Shows: DepthThe difference: The weak answer never removes old rows. At about 1.8 TB a year, the table and its index grow without limit, so storage and backups cost more every year.

Deep dive

Strong answer
The hard part is duplicate sends: a vendor can drop its acknowledgment, so a retry might send the same OTP twice. I would build an idempotency key from the user, template and a time bucket. I would save it in Redis before sending, and skip the send if the key is already there.
Weak answer
If sending fails or times out, I would keep retrying the vendor call until it succeeds, so the user always gets their notification.

Shows: DepthThe difference: Retrying without an idempotency key can deliver the same OTP or charge twice, since a lost acknowledgment looks like a lost send. The strong answer checks for that.

Failures and trade-offs

Strong answer
If a push notification fails, I would fall back to SMS only for high-priority transactional alerts, such as an OTP, after a short timeout. SMS costs far more per message than push, so using it for every failed promotional send would be too costly at 5,000 a second.
Weak answer
If a push notification fails, I would send it again by SMS. I would do that for every notification that fails.

Shows: Trade-offsThe difference: SMS costs more per message than push. Falling back for every failed send, including bulk promotions, is costly at thousands a second. The strong answer limits it to high-priority alerts.

We wrote this guide in our own words, informed by public interview guides such as AlgoMaster and Hello Interview. We are not connected to either site. Interviewers differ. The guide and the example answers show the direction each level takes, not a checklist.

10. Check your design with your own AI

Write your design first. Then copy this prompt into the AI chat you already use, and add your design at the end. It asks for a score in each area, one fix for each, and two follow-up questions.

The site sends nothing anywhere. An AI review can be wrong, so check what it says against sections 8 and 9.

See the prompt
You are a system design interviewer. Review my design for the interview problem below.

Problem: Design a Distributed Notification Service
Design a service that sends push messages, text messages and emails, at very large scale, without losing any.

What users must be able to do:
- Deliver push notifications (iOS APNS, Android FCM), SMS (Twilio), and Emails (SendGrid).
- Support user notification preferences and opt-outs.
- Provide delivery status tracking and retries.

How well it must work:
- Guaranteed at-least-once delivery.
- Low latency for transactional alerts (<5s).
- Prioritization (OTP alerts bypass promotional blasts).

Numbers to assume:
- 10 million notifications a day, with peaks of 5,000 a second during a campaign.

Judge my design at the Mid level.
A passing answer at this level: A complete design with numbers: about 120 notifications a second on average, bursting to 5,000 at peak during a campaign. It explains at-least-once delivery and goes deep on one part, such as duplicate sends.

For each area below, say whether my design is strong, fine or weak. Give one reason and one fix for each:
1. Requirements and scope
2. Estimates
3. Core design
4. Deep dive
5. Failures and trade-offs

Then ask me the two follow-up questions an interviewer would ask next.
Do not write a full model answer for me.

My design:
[Describe your parts, how one request moves through them, and why you chose each one.]