33. Design a Notification System
1
The interview prompt2
33.1 What do you ask first?3
33.2 How big is this, really?4
33.3 What are the doors?5
33.4 What do we store?6
33.5 What does the whole system look like?7
33.6 Why one queue per channel?8
33.7 How do retries and de-duplication work?9
33.8 How do user preferences work?10
33.9 What makes OTPs special?11
33.10 What would you say in the last five minutes?12
Score yourself13
Variations to practise14
Sources15
Code lab33. Design a Notification System
Score yourself
3 min read+10 XP
Score yourself
Give yourself 0, 1 or 2 points per row.
| Area | 0 points | 1 point | 2 points |
|---|---|---|---|
| Requirements | Started drawing | Listed channels | Channels, categories, latency per type, duplicates and opt-outs agreed |
| Estimates | None | Numbers, not used later | Numbers that showed isolation and provider limits are the real problems |
| API and data | Skipped | API or tables, not both | Async 202 API with idempotency key, OTP API separate, preferences and status modelled |
| High-level design | One queue, one worker | Queues and workers, no walkthrough | Order and OTP paths walked, receipts, campaigns separate |
| Deep dive | Hand-waved | One topic covered | Isolation, de-duplication, preferences or OTP security done properly |
| Trade-offs | None named | Named when asked | Raised unprompted (failover vs duplicates, SMS cost, priority vs separate queues) |
| Communication | Long silences | Mostly clear | Thought out loud, checked in, managed time |
12 to 14: strong hire signal. 8 to 11: solid, polish the weak rows. Under 8: redo the round in a week, timer on.
The bar: fresher vs SDE-2
| Fresher | SDE-2 | |
|---|---|---|
| Channels | Queue plus workers per channel | Separate lanes by priority with reserved provider quotas |
| Reliability | Retries | Backoff, failover, DLQ, staleness checks |
| Duplicates | Not mentioned | Idempotency at API, worker and provider |
| Preferences | Opt-out flag | Categories, quiet hours by time zone, caps, unsubscribe rules |
| OTP | Random 6 digits in a table | Crypto RNG, HMAC, TTL, attempts, resend limits, fraud, SMS weaknesses |
Common mistakes
- One queue for everything, so a campaign delays OTPs.
- Retrying by failing over to a second provider for every timeout, sending duplicates.
- Storing OTPs in plain text, or letting the calling service generate and log them.
- Applying marketing opt-outs to security messages, so users can't log in.
- Ignoring provider limits and cost, especially for SMS.
Quick check
Five questions on this chapter. Pick an answer, then check it.
quiz