Katkat

Design a Scalable Notification Service

SalesforceSoftware Engineer · Onsite

Last updated

Design an enterprise-grade, multi-channel notification platform capable of handling billions of notifications with durable ingestion, dynamic user preference filtering, idempotency, rate limits, and pluggable delivery providers.

Scenario

Salesforce powers critical communication workflows for millions of enterprises—ranging from urgent security alerts and transactional updates (e.g., password resets, order confirmations) to automated marketing digests. You are tasked with designing a centralized, highly reliable Notification Service capable of dispatching notifications across multiple channels (Email, SMS, Mobile Push, and In-App).

Functional Requirements

  • Multi-Channel Ingestion: Accept notification requests targeting multiple recipients across various channels (Email, SMS, Push, In-App/Webhook) via a unified API.
  • Explainable Filtering & Preferences: Evaluate user communication preferences (opt-outs, channel priority, quiet hours, and frequency capping). Maintain an audit trail explaining why any notification was sent, altered, or suppressed.
  • Quota & Rate Limiting: Enforce per-tenant and per-recipient rate limits to prevent spam, avoid noisy neighbors, and protect downstream provider quotas.
  • Guaranteed & Retry-Safe Delivery: Ensure at-least-once delivery for critical alerts with end-to-end idempotency, exponential backoff retries, and dead-letter queues (DLQ).
  • Extensible Provider Adapters: Provide an abstraction layer to integrate external delivery vendors (e.g., Twilio, SendGrid, APNs, FCM) with dynamic failover capabilities.

Scale & Non-Functional Requirements

  • Traffic Scale: 200 million notifications per day (~2,300 notifications/sec average, with bursts up to 25,000 notifications/sec during marketing campaigns or platform incidents).
  • Latency: Critical alerts (e.g., 2FA/OTPs) must deliver within 3 seconds (p99); bulk/marketing notifications can tolerate delivery within 15 minutes.
  • Reliability: 99.99% availability with zero message loss for transactional messages.
  • Idempotency: Prevent duplicate sends caused by network retries from upstream clients or internal worker restarts.

Key Areas to Address

  1. API & Data Model: Design the ingestion API schema and key data entities (templates, recipient preferences, delivery tasks, audit logs).
  2. High-Level Architecture: Diagram the flow from ingestion to routing, preference checking, rate limiting, and dispatch.
  3. Queueing & Priority Management: Explain your partitioning strategy, priority queues (critical vs. bulk), and backpressure handling.
  4. Failure Modes & Explainability: Detail how the service handles vendor outages, circuit breaking, idempotency keys, and structured audit logs.

Hints

Hint 1

Separate message ingestion from delivery workers using message queues partitioned by tenant or recipient ID to prevent cross-tenant starvation.

Hint 2

Decouple high-priority transactional traffic from low-priority bulk notifications via dedicated queues to avoid queue head-of-line blocking.

Hint 3

Implement idempotency using a deduplication store (e.g., Redis or DynamoDB with conditional writes) keyed by a client-provided idempotency key and recipient identifier.

Follow-up questions

  • How would you handle a sudden 500-error rate or throttling event from a third-party SMS vendor like Twilio without dropping in-flight messages?
  • How can you ensure explainability at scale so customer support can instantly query why a specific user did not receive an email 48 hours ago?
  • How would you implement user quiet hours across different timezones when sending scheduled mass notifications?