System Design Problems interview question · Most asked
Design a notification system (email, SMS, push).
Summary
Services publish notification requests to a queue; a notification service applies user preferences, templates, deduplication and rate limits, then routes to per-channel workers that call providers (SES, Twilio, APNs/FCM) with retries, recording delivery status.
Requirements
- Send email, SMS, push and in-app notifications
- Respect user preferences and quiet hours
- Templates and localization
- Retries, no duplicates, delivery tracking
- Handle spikes (marketing blasts) without delaying transactional messages
API
POST /api/notifications {"user_id": 42, "type": "order_shipped", "data": {...}, "idempotency_key": "..."}
GET /api/users/{id}/notifications?unread=true -- in-app inbox
PUT /api/users/{id}/notification-preferences
Data Model
notification_requests(id, idempotency_key UNIQUE, user_id, type, payload jsonb, created_at)
deliveries(id, request_id, channel, status, provider_id, attempts, last_error, updated_at)
preferences(user_id, type, channel, enabled, quiet_hours)
device_tokens(user_id, platform, token, last_seen)
Architecture
Producers → API/queue → notification service (validate, dedupe by idempotency key, load preferences, render templates) → per-channel queues with priority (transactional vs bulk) → channel workers calling providers → delivery status updates via provider webhooks. In-app notifications are written to an inbox table and pushed over WebSockets.
Deep Dives
- Priority isolation: separate queues/workers for transactional and marketing traffic
- Retries: exponential backoff; switch providers on sustained failures
- Dedup: idempotency keys and per-user/type rate limits (no 10 identical pushes)
- Token hygiene: remove invalid device tokens reported by APNs/FCM
- Compliance: unsubscribe links, opt-outs, data retention
Scaling
- Horizontal channel workers driven by queue depth
- Batch provider calls where supported
- Throttle to provider rate limits
Comparison / Tradeoffs
| Decision | Option chosen | Alternative | Why |
|---|---|---|---|
| Delivery | At-least-once + dedupe | Exactly-once | Practical with idempotency keys |
| Queues | Per channel and priority | One queue | Isolation of slow channels and bulk sends |
| Providers | Abstraction with failover | Single provider | Resilience to outages |
Explanation
What interviewers look for
A structured approach: clarify requirements and scale, sketch the API and data model, draw the high-level architecture, then go deep on the hardest component and discuss trade-offs, bottlenecks and failure modes.
Follow-up questions
- How do you schedule notifications in users' time zones?
- How would you build a digest (batching) feature?
More most-asked System Design Problems questions
- Design a URL shortener (like bit.ly).
- Design a distributed rate limiter.
- Design a chat application (like WhatsApp or Slack).
- Design a social media news feed (like Twitter/X or Instagram).
- Design a payment system.
- Design a ticket booking system (like Ticketmaster).
- Design a distributed unique ID generator.
- Design a webhook delivery system.