KatInterview

Design a Scalable Distributed Mass Email Delivery Engine

System DesignModel answer
MediumModel answerSystem Designsystem-designdistributed-systemsevent-driven

Last updated

Architect an enterprise marketing dispatch platform supporting timezone-aware scheduling, template rendering, deduplication, fault-tolerant ESP dispatch, and tracking.

Problem Overview

Design a high-throughput, fault-tolerant marketing email platform for a large global e-commerce and ticketing network. The system must dispatch scheduled targeted messaging, respect recipients' local operating hours across global timezones, dynamically inject user-specific profile data into templates, perform A/B experiment routing, and process engagement metrics (opens and clicks) without degradation.

Functional Requirements

  1. Timezone-Aware Dispatching: Schedule campaigns to trigger based on the user's local standard time across global regions.
  2. Template Customization & Experimentation: Support dynamic variable substitution and user-level A/B variant assignment.
  3. Engagement Analytics: Track individual open and click events with low-latency redirection.
  4. Suppression & Preference Handling: Enforce globally suppressive lists (unsubscribes, hard bounces, spam complaints) before dispatching.

Non-Functional Requirements & Key Scale Constraints

  • Volume: 10 million messages daily, subject to significant burst traffic (e.g., ticket drops) reaching up to 5,000 dispatches/sec peak.
  • Reliability & Idempotency: Zero silent message loss. At-most-once or effectively-once delivery guarantees (minimize accidental duplicate sends).
  • Extensibility: Multi-provider failover across external Email Service Providers (ESPs) like AWS SES or SendGrid.

Hints

Hint 1

Break down local time handling into localized dispatch buckets (e.g., 15-minute UTC intervals) mapped to standard IANA timezone identifiers rather than raw static offsets.

Hint 2

Ensure deterministic A/B routing using consistent hashing on campaign ID and user ID to avoid stateful lookup bottlenecks during bulk rendering.

Hint 3

Use a conditional ledger update (atomic state machine check) immediately before issuing an external ESP API request to guarantee idempotency across worker retries.