System Design beginner LIVE DEMO
πŸ””

Notification System Delivery Lifecycle Visualization

Walk through a scalable notification system from event intake and queue buffering through priority handling, preference checks, idempotency, provider dispatch, opt-out drops, retry backoff

System DesignNotification SystemMessage QueuesDeduplicationRetry Backoff
Interactive Demo

Continue with the guided workspace

Use the paired workspace to connect this guide's mental model with live component state, visible signals, and the outcome each step or scenario is meant to prove.

Mental Model

A highly available notification system must handle massive spikes in demand while reliably delivering alerts across multiple external channels (SMS, email, push notifications) that suffer from unpredictable downstream latency and outages.

For interactive exploration of these behaviors, you can run the live sandbox: Notification System Simulator.

Components and Why They Exist

Event Producer

The event producer represents upstream servicesβ€”such as payment processors, authentication systems, or marketing enginesβ€”that trigger user alerts. It emits notification request particles containing user metadata, channel preferences, template IDs, and a client-side idempotency key toward the API Gateway.

API Gateway

The API gateway serves as the single entry point that secures, validates, and quickly acknowledges notification requests. Every incoming request passes through authentication and schema validation checks at this gateway before being enqueued and returning a fast HTTP 202 Accepted status.

Message Queue (Kafka)

The Kafka message queue buffers high-volume notification events durably to isolate client-facing intake from slow external provider networks. Partitioned topics absorb burst traffic and reflect rising queue buffer levels during spikes so downstream worker nodes can consume events at a sustainable rate.

Priority Router

The priority router prevents bulk marketing alerts or low-priority digests from delaying urgent transactional alerts such as OTP verification codes. By inspecting the priority tag on queued messages, it routes urgent OTP items through dedicated fast-lane queues so they preempt promotional traffic in delivery order.

Notification Service

The notification service enforces core delivery policiesβ€”checking user preferences, rendering templates, and verifying idempotencyβ€”before external dispatch. It coordinates pre-dispatch lookups against the idempotency cache and preference database before routing validated messages to their target channel dispatchers.

Preference DB

The preference database stores user notification settings and channel opt-out states. When the notification service queries a recipient’s configuration, disallowed channels trigger an immediate drop rather than wasting external provider calls.

Idempotency Cache

The idempotency cache guards the system against sending duplicate notifications when upstream callers retry after network timeouts. Unique client-provided idempotency keys are recorded in this in-memory cache with a bounded Time-To-Live (TTL), allowing duplicate retry requests that hit an existing key to be discarded immediately.

Dispatchers (Push, SMS, Email)

Channel dispatchers abstract the provider-specific protocols of external networks such as APNs, FCM, Twilio, and SendGrid. Each dispatcher formats channel payloads and manages network transport toward the user device, while surfacing red error indicators whenever an external provider experiences an outage.

Retry Scheduler

The retry scheduler handles temporary network errors or provider outages without blocking active workers. Failed SMS or email deliveries route here to wait through an exponential backoff delay with random jitter before re-entering the dispatch queue.

User Device

The user device represents the final recipient endpoint for the notification. Once a channel dispatcher completes transport, the delivered push, SMS, or email payload arrives on the device card and updates the delivery status counter.

Edge Cases and Misconceptions

Idempotency Window Tradeoffs

It is a common misconception that idempotency caches should store keys forever. Retaining keys permanently is memory-prohibitive. Production systems assign a TTL (Time-To-Live) of 24–72 hours to idempotency records, assuming that any client-side network retry will occur within that timeframe. Retries after the TTL window can result in duplicate notification delivery.

DOWNSTREAM throttling and rate limiting

External provider networks (such as SMS gateways or email servers) have strict QPS limits. Ingesting traffic without queue buffering leads to provider rejection errors. Decoupling the ingestion layer using message queues allows dispatch workers to execute rate-limited calls safely.

Silent drops on User opt-out

For regulatory compliance, user opt-out states must be checked at the last possible layer before downstream dispatch. However, critical system alerts (like fraud warnings or password reset OTPs) must bypass these marketing preference filters to guarantee delivery. The system must categorise templates and allow structural bypass for critical classes.

Common Questions

Why is a message queue central to a notification system?

A queue decouples the high-speed event intake from slower, rate-limited downstream providers (like SMS and email APIs), preventing downstream delays from backing up client-facing services.

How does an idempotency check prevent double-delivery?

The client assigns a unique idempotency key to each notification request. The system stores this key in a fast cache (e.g., Redis) before calling providers. If a second request with the same key arrives, the system recognizes it as a duplicate and drops it.

Where should user preference checks occur in the delivery pipeline?

Preference checks should occur before dispatching messages to external providers. This saves provider costs, avoids wasting server resources, and ensures immediate compliance with opt-out settings.

Why is exponential backoff with jitter used for retries?

If an external provider suffers an outage, retrying immediately and repeatedly creates a thundering herd that keeps the provider overloaded. Exponential backoff increases the delay between attempts, and jitter adds randomness to prevent multiple workers from retrying at the exact same millisecond.