HLDArena
HLD-248·Messaging & Queues
Medium · 1,000 pts

Scalable Email Inbound Queue, Spam Filter & Thread Inbox

Design a Gmail / Fastmail-style inbound mail reception and mailbox storage pipeline that decouples MIME attachment blobs from per-user thread metadata, runs async spam/DKIM classification, and serves instant inbox folder views.

Max p99
≤ 55 ms
Availability
≥ 99.6%
Budget
≤ $6,200

Functional Requirements

  • FR-1POST /v1/inbound/messages — Validates SPF/DKIM, offloads large MIME attachments to object storage, and enqueues spam classification.
  • FR-2GET /v1/mailboxes/{mailbox_id}/threads — Returns paginated inbox/label thread summaries and unread counts in < 50 ms.
  • FR-3PATCH /v1/mailboxes/{mailbox_id}/threads/{thread_id} — Updates read/archive/label flags and refreshes cached unread counters.
  • FR-4Must never lose accepted inbound mail (RPO = 0 after 250 OK) when a primary mailbox metadata shard crashes.

Workload Profile

Steady Mail Traffic35,000 Inbox Read RPS / 7,500 Inbound & Flag Write RPS
Top-of-Hour Bulk Newsletter Wave90,000 Read RPS / 21,000 Inbound Write RPS
Active Working Set30 GB hot inbox first-page thread lists & unread label counters
Durability GateZero lost accepted messages + blob/metadata separation

Consistency Model

Read-after-write on user mark-as-read / archive actions; durable queued delivery for inbound SMTP receipts.

Relevant practice for

Click an item in Inventory above, or press B to add a component, double-click to name, C to connect.

Design Write-up

Write under ### Architecture for Diagram to take that up directly

Compulsory section · if not written yet, Diagram reads from the start of your write-up.
Architecture: required·FRs mentioned: 0/4·0 boxes · 0 edges
0 words
Hidden Cases #4–#7 run automatically on Submit
Case 1: Smoke & API ContractInput Workload
Read RPS
2,000 rps
Write RPS
400 rps
Key Distribution
Uniform (Low Skew)
Chaos Fault
None (Healthy Cluster)
Expected Pass CriteriaASSERTIONS
• Tail Latency: p99 ≤ 110 ms
• Availability: ≥ 99.6%
Valid end-to-end Client → Compute → Storage topology