Designing a Notification System: A System Design Interview Walkthrough
5 views
"Design a notification service that sends push, email and SMS messages" is a favourite system design interview question because it looks simple and quickly turns into a discussion about queues, retries, rate limits and user preferences. Here is a structure you can adapt in a 45-minute round.
1. Clarify requirements
Functional: other services trigger notifications through an API; channels are mobile push, email and SMS; users can opt out per channel and per category; some messages are scheduled; templates support localisation. Non-functional: high throughput (say 50 million notifications per day with bursts during marketing campaigns), at-least-once delivery, low latency for transactional messages such as one-time passcodes, and no spamming users at 3 a.m. in their time zone.
2. High-level design
Producers call a Notification API, which validates the request, checks the preference service, renders the template and writes an event to a message queue. Separate worker pools consume per channel: a push worker talks to APNs and FCM, an email worker to an email provider, an SMS worker to an SMS gateway. Splitting queues by channel and priority means a slow email provider never delays a login code sent by SMS.
3. Data model
Store user contact info and device tokens, a preferences table keyed by user and category, templates with versions, and a notification log (id, user, channel, status, attempts, timestamps). The log supports idempotency and gives customer support a way to answer "why didn't I get my code?"
4. Reliability
Use idempotency keys so a retried API call does not send twice. Workers retry with exponential backoff and move poison messages to a dead-letter queue. Track provider responses: invalid device tokens should be removed, and hard email bounces should mark the address as undeliverable. Mention a fallback, such as switching to a secondary SMS provider when the primary error rate spikes.
5. Rate limiting and user experience
Apply per-user caps (for example, no more than three marketing pushes a day), quiet hours based on time zone, and deduplication windows so ten likes become one "10 people liked your post" digest. Interviewers love hearing that you care about the user, not just throughput.
6. Scaling and monitoring
Workers are stateless and scale horizontally on queue depth. Partition the queue by user id to keep per-user ordering where it matters. Monitor send rate, delivery rate per provider, latency percentiles and opt-out rate after campaigns.
7. Trade-offs to discuss
At-least-once versus exactly-once delivery, push versus pull for in-app notifications, and building a scheduler versus using delayed queues. Naming a trade-off and explaining your choice is worth more than drawing extra boxes.
Practise saying this aloud, because structure is easy to lose under pressure. If you want support during the real thing, Linkjob AI (https://linkjob.ai) gives real-time help during live job interviews and technical interviews, so you can keep your design discussion organised when the interviewer starts changing the requirements.