System Design: Building a Notification Service
Notifications are deceptively complex. You need reliability, speed, and user control, all without spamming anyone.
Core Requirements
- Deliver across channels (email, push, SMS).
- Allow user preferences.
- Support retries and deduplication.
High-Level Architecture
- Producer service emits events.
- Queue buffers delivery jobs.
- Workers send messages.
- Status stored for retries.
Idempotency Matters
Duplicate deliveries feel like bugs. Use an idempotency key per notification and store delivery status.
Retry Strategy
- Exponential backoff.
- Dead letter queue after max retries.
- Alert on permanent failures.
Preference Management
Store preferences per user and enforce them before enqueueing. This avoids accidental delivery.
Final Thought
A notification system is a reliability system. Start with correctness, then optimize throughput.
Related Articles
Unique ID generatorβββTwitter snow flake design
DESIGN In large distributed systems, something that looks simple on the surface β generating a unique ID β becomes surprisingly hard. When millions of users are...
Strategies to Scale Database Writes
In the previous article [https://medium.com/@akshatjme/5671a7ac80e1], we saw how to scale reads by reducing the amount of work the database has to do for every...
Strategies to Scale Database Reads
Learn how to scale database reads as traffic grows through replicas, caching, materialized views, denormalization, and other proven techniques that reduce repeated work.