System design · Question 49 of 50

Design a notification system: email, SMS and push.

What they're checking

Fan-out, retries, preferences and rate limits.

The answer

Services call one notification API ("order shipped, user 42"). It checks the user's preferences and quiet hours, picks the channels, fills in the template, and puts one message per channel on that channel's queue. Channel workers call the providers (an email service, an SMS gateway, APNs and FCM for push) with retries and backoff, and fall back to a second provider if one is down.

Make it idempotent (a dedupe key per event and user, so a retry never sends twice), rate-limit per user (never 20 pushes in a minute), and record every send's status for support and analytics. Marketing campaigns go on a separate, lower-priority queue so they never delay an OTP.

The picture

order service ─▶ notify API ─▶ preferences + template
                                  ├─▶ [ email queue ] ─▶ worker ─▶ email provider
                                  ├─▶ [ SMS queue ]   ─▶ worker ─▶ SMS gateway
                                  └─▶ [ push queue ]  ─▶ worker ─▶ APNs / FCM
OTPs: high-priority queue     campaigns: low-priority queue
The follow-up they'll ask

How do you send to 10 million users?

Show the answer

Feed the fan-out into the queue in batches, scale the workers, respect each provider's rate limits, and spread it over time.

Your progress stays on this device.