Advanced60 min

Design a Notification Service

An educational design exercise, not a description of any company’s real system.

01Problem

Design a notification platform used by every product team in a large consumer company. A service such as Orders or Security calls the platform with "notify user 42 that order 981 has shipped" or "send this campaign to 50 million users", and the platform decides which channels to use (push, email, SMS), respects the user's preferences and quiet hours, renders the right template and language, and hands each message to an external provider such as a push gateway, an email delivery service or an SMS aggregator.

Notifications vary enormously in urgency and volume. A one-time login code must arrive within seconds and exactly once from the user's point of view, while a marketing campaign can take an hour but produces bursts of tens of thousands of messages per second. External providers are slow, rate limited and sometimes down. The platform must not lose important messages, must not spam users with duplicates, and must keep campaigns from delaying urgent traffic.

02Functional requirements

  • Accept a notification for a single user (by user id, category, template and data) and deliver it on the channels allowed by the category and the user's preferences.
  • Accept campaigns that target a segment of users, scheduled for a time or sent immediately, and fan them out at a controlled rate.
  • Manage per-user preferences: opt in/out per category and channel, quiet hours in the user's time zone, one-click email unsubscribe; register and remove push device tokens.
  • Render templates per channel and locale with variables supplied by the caller; templates are versioned and owned by the calling teams.
  • Track the status of each delivery (queued, sent, delivered, bounced, failed) using provider callbacks, queryable for 90 days.
  • Retry transient failures, fail over between providers where a second provider exists, and suppress addresses that bounce or tokens that are invalid.

03Non-functional requirements

  • About 200 million deliveries per day (150M push, 40M email, 10M SMS); a campaign can target 50 million users and must finish within 1 hour.
  • Transactional notifications (login codes, password resets, security alerts) handed to the provider within 5 seconds at p99; bulk/marketing within 1 hour.
  • At-least-once delivery to providers with deduplication: the same request (same idempotency key) must not produce a second message within 24 hours under normal operation.
  • Accepted notifications are durable: once the API returns 202, a notification is not lost even if workers or a datacenter zone fail.
  • Respect provider contract limits (e.g. 1,000 SMS/s per provider account) and per-user frequency caps (e.g. at most 3 marketing pushes per day).
  • API availability 99.95%; campaigns must never delay transactional traffic.

04Clarifying questions

Ask these first. Open one to see the answer the interviewer gives.

  • Who calls the service, and who owns templates and content?

    Only internal services, authenticated with service credentials. Each team owns its templates and categories; the platform provides the template store and rendering.

  • Which channels are in scope?

    Push (iOS and Android through the platform push gateways), email and SMS. An in-app inbox is out of scope for now but should be easy to add as another channel.

  • What delivery guarantee do callers need?

    No accepted notification may be silently lost. Duplicates should be avoided but an occasional duplicate under failure is acceptable for most categories; for login codes a duplicate is better than a missing message.

  • How do preferences interact with categories?

    Each category has a default channel policy and a type: transactional or marketing. Users can opt out of marketing per category and channel. Transactional security messages ignore marketing opt-outs and quiet hours, but never go to channels the user has removed (no phone number means no SMS).

  • Do we have multiple providers per channel?

    Two providers for email and two for SMS, with different prices and limits. Push goes only through the platform gateways for iOS and Android, so there is no failover target for push.

  • What volume and burst profile should we design for?

    200M deliveries per day on average, about 20% transactional. Campaigns to up to 50M users finish within an hour. Assume transactional traffic peaks at 3x its average.

  • Do we need to know whether a message was delivered or opened?

    Delivered/bounced status from provider callbacks, yes, for 90 days. Opens and clicks are a nice-to-have for marketing and can come later.

  1. Capacity estimation
  2. API design
  3. Data model
  4. High-level architecture
  5. Component deep dive
  6. Scaling strategy
  7. Failure handling
  8. Security
  9. Observability
  10. Trade-offs
  11. Alternative designs
  12. Follow-up questions