Back to sketch

SYSTEM DESIGN SKETCHBOOK / PRACTICE SHEET / NO. 24

Design a notification service

Advanced · 45 min · Queues & streams

Many internal teams need to tell users things: a password reset code, "your order shipped", "someone commented on your photo", a weekly digest, a marketing campaign. They call one shared service, which decides how to reach each person and hands the message to outside providers for push, email and SMS.

Requirements

  • Accept a notification request (user, category, template data) from internal producers and acknowledge it quickly.
  • Choose channels per user from their preferences and the category: opt-outs, quiet hours, verified email or phone.
  • Deliver through third-party push, email and SMS providers, retrying failures, and never deliver the same notification twice on the same channel.
  • Limit how many low-priority notifications one user receives, and record the delivery status of each notification.

Constraints and assumptions

  • 2 billion notifications a day (about 23,000 per second on average); campaigns add bursts of 50 million recipients over 10 minutes.
  • Channel mix: 80% push, 18% email, 2% SMS.
  • Security codes and password resets must be handed to a provider within 5 seconds at p99, even during a campaign burst.
  • Providers enforce their own rate limits (for example 1,000 SMS per second per account) and sometimes fail or slow down for minutes at a time.
  • 300 million users with stored preferences and an average of 1.5 devices each.

Out of scope for the first sketch

Building the push, email or SMS providers · Template authoring and localization · An in-app notification inbox

Draw your design

Rough math and notes

Done on paper? Compare with the worked approaches