Book a 30-min callBook a call

System design: a notification system for email, push and SMS

How to design notifications: preferences, templates, quiet hours by time zone, dedupe keys, per-channel queues, retries, push tokens, bounces and unsubscribe.

An event card flowing through a service box with a filter and a clock, then splitting into three queues to a phone, an envelope and a chat bubble, with a dashed arrow returning status.
Written by
BYD Tech
Published
Topic
Deep dives
Reading time
15 min read

Questions people ask

How do you stop a notification from being sent twice?

Deduplicate at every hop. Store the producer’s event id with a unique constraint, give every notification a dedupe key built from the event id, the recipient and the channel under a unique index, and pass your notification id to the provider as an idempotency key where it accepts one. Retries then find the existing row and do nothing.

Should quiet hours apply to email?

Usually not, because an email does not wake anyone, but it is a product decision. Quiet hours matter most for push and SMS. Compute them in the recipient’s IANA time zone, defer what is not urgent to the end of the window, and let a short list of critical categories, such as security alerts, through.

What happens to push tokens when a user reinstalls the app?

The app gets a new token, and the old one stops working. Apple notes that APNs issues new tokens on a new device, a restore from backup or an operating system reinstall. Send the token to your server on every launch, and delete old tokens when APNs answers 410 or FCM answers UNREGISTERED.

Do transactional emails need one-click unsubscribe?

Not under Google’s sender rules: one-click unsubscribe is required for marketing and subscribed messages, and Google’s FAQ says transactional messages such as password resets are excluded. Users still need a way to control optional notifications, and the law where your users live may ask for more.

Building something like this?