Chapter Fifteen · Problem Nine

Notification System

The sending belongs to someone else. The design is everything around that call: queues that keep a sign-in code clear of a campaign, and a rule for each outcome you cannot know.

4 lessons · 45 minutes
The Question

"Design a system that sends push notifications, text messages and email to users when other services ask it to."

The sentence makes this sound like a job about sending, and you do none of it. A push service, an email sender and a text-message gateway do the delivering, each run by another company, each with its own speed, limits and way of failing. The design is everything around a call you do not control: what waits for it, what happens when it does not answer, and what you do when you cannot tell whether it went through.

Most of the parts come from Chapter 6. Delivery Semantics at Scale supplies the duplicate, Backpressure and Load Shedding the flood, and Failure Across Many Services the company that stops answering. Chapter 2's Caching at Scale covers the read every send makes, and Chapter 4's Consistency Models That Come Up covers how soon a mute holds.

This one suits a mid-level round, where a sound queue and workers per channel are the bar. A senior candidate is judged on pricing a duplicate differently per channel without being asked. Three pressures shape it. Many services fan in, and the messages fan out to providers that differ in speed, limits and failure. Delivery is at-least-once, and a duplicate costs something different on each channel: a second text message is money and annoyance. And messages are not equal, so preferences, quiet hours, per-user caps and priority have to keep a sign-in code apart from a marketing blast.

Before you open Scope, set a timer for 45 minutes, take a blank page, and work out what your design does with a sign-in code sent one second after a campaign starts. Scope ends at minute 10, First Design at minute 20, Scaling It at minute 30, and the deep dives and curveballs run out the clock. Then hold your answer about that code against the one these lessons reach.

The 45 minutes of this problem, lesson by lesson
Scopeminutes 0-10
→
First Designminutes 10-20
→
Scaling Itminutes 20-30
→
Deep Divesminutes 30-45

Lessons in This Chapter