Answer
Requirements: send push, SMS and email notifications triggered by other services or on a schedule, respect user preferences and opt-outs, and deliver reliably at high volume with soft real-time latency.
- Components: a notification API that validates requests, a preference and device-token store, a template service, and a separate message queue per channel so that a slow provider does not block the others.
- Workers: channel workers call third-party providers such as APNs, FCM, an SMS gateway or an email service, retrying with exponential backoff and moving repeated failures to a dead-letter queue.
- Safeguards: per-user rate limits, deduplication keys, and delivery tracking for analytics.
- Trade-off: queues give at-least-once delivery, so duplicates are possible; deduplication reduces them, but exactly-once delivery to a device cannot be guaranteed.
More in Web Services
| # | Problem | Platform | Difficulty | Open | 1st1st Visit | 2nd2nd Visit | RevRevise |
|---|---|---|---|---|---|---|---|
| 1 | Design a URL shortener | Concept | Medium | Read the answer to Design a URL shortener | |||
| 2 | Design a pastebin service | Concept | Medium | Read the answer to Design a pastebin service | |||
| 3 | Design a rate limiter | Concept | Medium | Read the answer to Design a rate limiter | |||
| 4 | Design a notification system | Concept | Hard | Read the answer to Design a notification system |