Design a Notification System

Problem Design a notification system that delivers push, SMS and email notifications to users for events such as order updates, promotional offers and reminders.

Functional requirements

  • Accept notification-worthy events from many upstream services.
  • Render per-type, per-locale templates.
  • Respect user channel preferences and unsubscribe/opt-out.
  • Route to the right channel(s): push (APNs/FCM), SMS gateway, email provider.
  • Rate-limit per user so a burst of events doesn't spam them.
  • Retry failed deliveries and expose delivery status/history for an in-app notification center.

Non-functional requirements

  • ~50M registered users; ~500M notifications/day → ~6k/sec average, with marketing blasts spiking to ~100k/sec for minutes at a time.
  • Transactional notifications (OTP, order status) p99 < 5 s end-to-end; marketing sends may take minutes.
  • 99.9% delivery success to the provider, excluding invalid tokens/numbers.
  • Store 90 days of delivery history: ~45B rows, time-partitioned with TTL/archival.
  • Per-provider throughput caps (e.g. an SMS gateway allowing 2k/sec) are a hard external constraint.

Areas to go deep

  • Decoupling ingestion from delivery and isolating transactional from bulk traffic.
  • Per-user ordering, rate-limiting, and idempotency under at-least-once delivery.
  • Retry/backoff policy, invalid-token pruning, and delivery-status write amplification.
asked …
LeaderboardSalaryAccount