System Design blueprint · Tech & SaaS
Notification service at scale
One service turns product events into push, email and SMS, honouring preferences and priorities.
- Steps
- 6
- Subjective questions
- 32
- Objective questions
- 32
The problem and the outcome
Problem: Every team sends messages its own way, so users get duplicates, spam and missed OTPs.
Outcome: One pipeline, the right channel per user, and urgent messages first.
Architecture
How it works, step by step
- Services publish an event instead of sending messages themselves.
- The notification service loads the user's channels, quiet hours and the right template.
- Messages go onto priority queues, so an OTP never waits behind a newsletter.
- Channel workers deliver through APNs/FCM, an email provider or an SMS gateway, with retries.
- Every delivery, open and bounce is logged for analytics and de-duplication.
- Per-user rate limits stop a burst of events from flooding anyone's phone.
Tech stack
- Kafka or SQS
- Priority queues per channel
- APNs / FCM, SES / SendGrid, Twilio / MSG91
- Template service
- Preference store
Key design decisions
- One service owns sending, so preferences, quiet hours, rate limits and deduplication are applied in one place.
- Separate queues per priority and per channel, so an OTP never waits behind a marketing blast.
- Idempotent sends keyed by event and channel, so a retried event does not notify twice.
Common mistakes
- Sending marketing messages through the same queue as OTPs and security alerts.
- Ignoring provider rate limits and getting throttled or blocklisted.
- No unsubscribe or preference check, which breaks laws such as CAN-SPAM, GDPR and DND/TRAI rules.
What to measure
- Delivery and open rate per channel
- OTP time-to-deliver
- Bounce and complaint rates
- Queue depth per priority
Most-asked interview questions
Subjective questions 32
1Design a notification system that sends push, email and SMS.Asked almost every time
Product services publish events. The notification service looks up the user's preferences and the template, decides the channels, deduplicates, and puts a job on the right priority queue. Workers per channel call the providers with retries and backoff, and record delivery status in a log that feeds analytics and suppression lists.
2How do you respect user notification preferences?Asked almost every time
Store preferences per user, channel and category (marketing, security, order updates) plus quiet hours and time zone, check them in the notification service before sending, always allow critical security messages per policy, and make unsubscribe links work in one click.
3How do you handle provider failures for email or SMS?Asked almost every time
Wrap each provider behind an interface, retry transient errors with backoff, fail over to a secondary provider when error rates rise, track delivery receipts, and move messages that keep failing to a dead-letter queue.
4How would you design templates and localisation?Asked almost every time
Keep templates versioned in a template service with placeholders, render per locale with fallbacks, preview and test them before release, escape user data, and store which template version was sent for auditing.
5How do you avoid sending the same notification twice?Very often asked
Give each notification a deterministic ID (event ID + user + channel) and record it before or atomically with sending; a retry sees the record and skips. Providers that support idempotency keys get the same ID.
6How would you send a campaign to 50 million users without hurting OTP delivery?Very often asked
Run it on a separate low-priority queue with its own workers and rate limit, batch the sends, spread them over time, and respect each provider's throughput. Transactional messages keep reserved capacity.
7How do you deduplicate and rate-limit notifications per user?Very often asked
Use an idempotency key per logical notification (event ID plus user plus channel), and per-user rate limits or digests so users do not receive ten pushes in a minute; collapse similar notifications into one.
8How do you schedule notifications in users' time zones?Very often asked
Store each user's time zone, compute send times in UTC, and use a scheduler or delay queue to release messages at the right time, respecting quiet hours.
9How do push notifications work end to end?Very often asked
The app registers with APNs or FCM and gets a device token, which your backend stores per user and device. To send, you call the provider with the token and payload; it delivers to the device. Invalid tokens are reported back and must be removed.
10How do you track whether notifications were delivered and read?Very often asked
Record provider delivery receipts and webhooks (delivered, bounced, opened, clicked), store status per message, and use tracking links or app events for opens, while respecting privacy rules.
11How do you handle in-app notifications?Very often asked
Store them in a per-user inbox table with read status, deliver live over WebSockets or SSE when the user is online, and show unread counts; push or email can follow for users who are offline.
12How do you protect email deliverability?Very often asked
Authenticate with SPF, DKIM and DMARC, use a dedicated sending domain, warm up new IPs, remove bounced and complaining addresses, keep marketing and transactional mail separate, and monitor spam complaint rates.
13What is a digest notification?Very often asked
Batching several events into one message (for example a daily summary of comments) instead of sending each one, which reduces noise and improves engagement for low-urgency updates.
14How would you design the notification data model for many channels?Very often asked
Store one notification record per event and user with type, payload and template, then one delivery record per channel attempt with status, provider ID and timestamps. Preferences live per user, type and channel, so the router can decide channels without touching producers.
15How do you guarantee an OTP arrives quickly even during a marketing blast?Very often asked
Put transactional messages on a separate high-priority queue with reserved worker capacity and provider throughput, use a dedicated sending number or subdomain, set a short validity and fall back to another provider or channel if delivery is not confirmed within seconds.
16How do you keep the notification service decoupled from producers?Often asked
Producers publish domain events or a generic 'send notification' request to a queue with the user, category and data; the notification service owns channels, templates and preferences, so producers do not know about providers.
17How do you handle SMS costs and regulations?Often asked
Use SMS only for urgent or OTP messages, route through approved templates and sender IDs where regulation requires (such as DLT registration in India), track cost per country, and prefer push or email for the rest.
18How do you test notifications safely?Often asked
Use sandbox providers or test numbers, route non-production environments to a catch-all inbox, never send to real users from staging, and add automated template rendering tests.
19What happens when a device token becomes invalid?Often asked
The push provider returns an error or feedback; delete or deactivate that token so you stop sending to it, which keeps send costs and error rates down.
20How do you prioritise OTPs over marketing?Often asked
Use separate queues and worker pools by priority, with OTPs on a high-priority queue that is never blocked by bulk campaigns, and dedicated provider routes for critical traffic.
21How do you send a campaign to millions of users?Often asked
Segment users in batches, enqueue jobs gradually with rate limits matched to provider limits, track progress, allow pausing and cancelling, and respect preferences and quiet hours per user.
22How do webhooks from providers fit in?Often asked
Providers call your webhook with delivery events; verify signatures, store events, update message status idempotently and handle bounces and complaints automatically.
23How do you make notifications accessible and useful?Often asked
Write clear, short messages with the key information first, include deep links to the exact screen, support screen readers in in-app inboxes, and avoid relying on colour or images alone.
24How do you let users unsubscribe in one click from an email?Often asked
Include a signed unsubscribe link and the List-Unsubscribe and List-Unsubscribe-Post headers, process the request without a login, update preferences immediately for that category, and confirm on a page that offers to manage other categories.
25How would you build a notification centre with unread counts?Often asked
Store in-app notifications per user sorted by time, keep an unread counter updated on insert and on read, push changes over WebSocket or SSE, mark items read in batches, and paginate with cursors. Recompute the counter periodically to correct drift.
26How do you A/B test notification content?Often asked
Assign users to variants deterministically, send each variant's template, and measure open, click and conversion plus unsubscribe and complaint rates. Stop variants that raise opt-outs even if clicks rise, and keep a holdout group that receives nothing to measure the true lift.
27How do you handle notifications for users with several devices?Often asked
Register every device token per user, send push to all active devices, sync read state so reading on one clears the badge on the others, and expire tokens not seen for a while to avoid wasted sends.
28What data should a notification record store?Sometimes asked
User, channel, category, template and version, rendered content or reference, status history with timestamps, provider message ID and correlation to the triggering event.
29How do you measure notification quality?Sometimes asked
Track delivery rate, open and click rates, unsubscribe and complaint rates, time to deliver, and the effect on user actions, comparing categories and channels.
30What is a fallback channel?Sometimes asked
If a push is not delivered or opened within a time window, send the same important message by email or SMS, so critical updates reach the user.
31How do you comply with privacy rules in notifications?Sometimes asked
Collect consent for marketing, honour opt-outs immediately, avoid sensitive data in message content, and keep audit logs of consent and sends.
32How do you send WhatsApp business notifications?Sometimes asked
Use the WhatsApp Business Platform through a provider, send only pre-approved templates outside the 24-hour customer service window, get explicit opt-in, and track delivery and read webhooks just like other channels.
Objective questions 32
1Which message should go on the highest-priority queue?Asked almost every time
Why: An OTP is time-critical; the user is waiting for it right now.
2Which messages may bypass marketing opt-outs per policy?Asked almost every time
Why: Users still expect security alerts.
3What should happen when an email provider's error rate spikes?Asked almost every time
Why: Providers sit behind an interface.
4What key prevents sending one notification twice?Asked almost every time
Why: An idempotency key per logical message.
5Which services deliver mobile push notifications?Very often asked
Why: Apple Push Notification service and Firebase Cloud Messaging deliver to iOS and Android devices.
6Which services deliver push to iOS and Android?Very often asked
Why: Apple and Google push services.
7Which records authenticate your sending domain?Very often asked
Why: They protect deliverability.
8A digest notification…Very often asked
Why: It reduces notification noise.
9When should a device token be removed?Very often asked
Why: Saves cost and errors.
10Where are in-app notifications stored?Very often asked
Why: Delivered live when online.
11How should quiet hours be applied?Very often asked
Why: Store time zones per user.
12Which design lets channels change without touching producers?Very often asked
Why: Producers publish events; routing stays in one place.
13What keeps OTPs fast during a marketing campaign?Very often asked
Why: Bulk sends must not delay security codes.
14What should happen to an address that hard-bounces?Often asked
Why: Repeated sends to bad addresses hurt your sender reputation, so stop sending to them.
15Which messages should go on separate high-priority queues?Often asked
Why: Bulk sends must not delay them.
16What must staging environments avoid?Often asked
Why: Route to catch-all inboxes.
17What does a fallback channel do?Often asked
Why: Ensures critical delivery.
18What should be checked before sending marketing messages?Often asked
Why: Privacy rules require consent.
19Why keep producers unaware of providers?Often asked
Why: This keeps services loosely coupled.
20What should a large campaign send rate match?Often asked
Why: Avoid throttling and blocks.
21Which events update delivery status?Often asked
Why: Delivered, bounced, opened.
22SMS in India for businesses requires…Often asked
Why: A regulatory requirement.
23Which email header supports one-click unsubscribe?Often asked
Why: Mail providers show an unsubscribe button using it.
24Unread counts drift less if you…Often asked
Why: A periodic correction fixes missed updates.
25A holdout group in notification tests…Often asked
Why: It shows what happens without the message.
26Reading a notification on one device should…Often asked
Why: Read state must sync across devices.
27Which metric shows users dislike your messages?Sometimes asked
Why: Rising rates hurt deliverability.
28Why store the template version with each send?Sometimes asked
Why: Templates change over time.
29Notifications should deep-link to…Sometimes asked
Why: Saves the user steps.
30Bounced email addresses should be…Sometimes asked
Why: Protects sender reputation.
31Collapsing similar notifications avoids…Sometimes asked
Why: One message instead of ten.
32Outside the 24-hour window, WhatsApp business messages must use…Sometimes asked
Why: Meta's rules require approved templates for business-initiated messages.
Track your progress through every blueprint in your dashboard.
Start learning