Loading…
A short voice session: one question, one follow-up, then instant feedback — up to 5 minutes.
I would separate notification creation from delivery using a durable queue and independent workers for each channel. The design should include retries with backoff, idempotency, provider failover, rate limits, user preferences, and observability.
The first architectural decision is to avoid making the business service synchronously send email, SMS, or push notifications. Instead, it creates a notification event and places it on a durable queue.
A possible architecture is:
Business Services
|
Notification API
|
Durable Queue
/ | \
Email SMS Push Workers
| | |
Provider Provider ProviderThe notification service should store enough information to track delivery state. Workers consume messages and call external providers. Different channels can have independent workers and scaling policies.
Reliability requires retries, but retries must be controlled. Exponential backoff with jitter helps avoid overwhelming a provider after an outage. Messages that repeatedly fail can go to a dead-letter queue for investigation or later replay.
Exactly-once delivery is generally difficult when external providers are involved. Instead, the system should aim for effectively-once business processing through idempotency and provider-specific message identifiers where possible.
Provider failures should not necessarily stop the whole system. For example, an SMS provider can have a secondary provider configured for failover. Rate limits must also be enforced per provider and potentially per user.
The system should respect user preferences, unsubscribe rules, quiet hours where applicable, and legal requirements. Observability should include queue depth, delivery latency, success/failure rates, retry counts, provider errors, and dead-letter queue size.