Dashboard/System design/37. Design WhatsApp

SYSTEM DESIGN · LESSON 37 OF 52 · 14 MIN VIDEO · 5 TOPICS

Design WhatsApp

Module Progress (0 / 5 Lessons Completed)0%
System design Track (0 / 52 Modules) · Overall 0/80 (0%)0%
⌁

Narrated HD Video Lesson (14 min) · Pro

Lesson Overview + Section #01 + RESHADED Checklist + Quiz #1 are unlocked free below (no login required). Unlock all 80 HD video lessons and deep-dive sections — or watch our two free sample video lessons first.

0% READSec 01/05 · System Design: WhatsApp
SYSTEM DESIGN VIDEO LESSON & GUIDE

Design WhatsApp

WhatsApp delivers ~100 billion messages/day across 2 billion active mobile users (~1.16 million messages/s average) with sub-second push latency, strict per-conversation ordering, exact-once user-visible delivery, 30-day offline persistence, and end-to-end encryption (E2EE). Unlike cloud-archived workspaces, WhatsApp operates as a stateful transient delivery relay—holding millions of persistent WebSocket connections open while persisting undelivered ciphertext only until acknowledged by the recipient device. L4-L6 interviewers evaluate stateful gateway sizing, sub-millisecond session routing in Redis, decoupling heavy media and group fan-out from real-time chat sockets, and handling reconnect storms when multi-million-socket gateways fail.

WHAT YOU WILL MASTER IN THIS LESSON
  • Size a stateful C10M-class WebSocket fleet (200 gateways at 10M open connections/server), daily text ingress (10 TB/day, 926 Mbps), and 30-day offline storage buffers (300 TB).
  • Architect sub-millisecond cross-gateway message routing using a Redis-backed WebSocket Manager paired with replicated Mnesia store-and-forward persistence and APNs/FCM wakeups.
  • Offload 2 MB+ encrypted media payloads onto an HTTP Asset Service, content-addressed Blob Store, and edge CDN while keeping WebSocket chat frames around ~100 bytes.
  • Preserve total per-chat ordering and exact-once semantics via monotonic sequence numbers, hop-by-hop acknowledgements, per-group Kafka topics, and jittered crash reconnection.
SYSTEMATIC INTERVIEW CHECKLIST · RESHADED + 45-MIN CLOCK

8-Step RESHADED Execution Checklist

Follow this exact sequence from the Intro narration on every system design prompt so you never miss requirements, math, contracts, or the 13-minute deep dive.

0 / 8 Checked
INTERVIEWER SCORECARD · WHAT MAKES A STRONG HIRE?

5 Signals Bar Raisers Grade (L4 vs. L5 Senior vs. L6 Staff)

Senior (L5 / E5 / Senior SDE) Bar — Autonomous Pacing, Depth & Proactive Trade-Offs: Owns the 45-minute clock without prompting, derives every component quantitatively, surfaces failure modes (hot shards, stampedes, dual writes) BEFORE being asked, and defends consistency vs. latency trade-offs.
1. Scoping
✓ STRONG HIRE SIGNAL

Clarifies users, read/write skew, p99 latency, consistency bounds, and explicit non-goals in minutes 2–8.

✗ NO-HIRE RED FLAG

Jumps straight into drawing load balancers and microservices at minute 2 without asking a single question.

2. Right-Sized Design
✓ STRONG HIRE SIGNAL

Starts with the simplest working architecture justified by the math (e.g., 1 NVMe SQL primary + replicas + Redis for 40 writes/s & 3 TB).

✗ NO-HIRE RED FLAG

Recites a memorized Kafka + multi-DC Cassandra diagram that contradicts their own traffic calculations.

3. Technical Depth
✓ STRONG HIRE SIGNAL

Drives deep into 1–2 hard bottlenecks (partition keys, hot-key mitigation, transactional outbox, KV-cache batching) at minute 27.

✗ NO-HIRE RED FLAG

Skims across 12 boxes at identical buzzword depth and runs out of time before the deep dive.

4. Explicit Trade-Offs
✓ STRONG HIRE SIGNAL

Uses 3-part reasoning: 'A queue here because SMTP spikes to 3 s; checkout stays <60 ms, and we accept eventual email delay + retry dedup.'

✗ NO-HIRE RED FLAG

Name-drops tools ('We put Kafka and ZooKeeper here') without stating the alternative or operational cost.

5. Communication
✓ STRONG HIRE SIGNAL

Thinks aloud every 30–45s, checks alignment at phase transitions, and treats 'What if X fails?' as a cue for where points are awarded.

✗ NO-HIRE RED FLAG

Goes silent for 5 minutes while drawing or defends a flawed assumption defensively when nudged.

ARCHITECTURE & DATA-FLOW SLIDES · SLIDE 1 OF 1Section 01: System Design: WhatsApp
ARCHITECTURE / DATA FLOW DIAGRAM
photo, 2 MBAshaphonegroup of 200WhatsApp servers1 hi, 2 how are youBenphone
SECTION 01 OF 5

1. System Design: WhatsApp

★ FREE PREVIEW
Key Takeaway: Mobile devices behind NAT and intermittent cellular networks cannot message peer-to-peer reliably; WhatsApp solves planetary-scale delivery with two invariants: keep long-lived sockets open to online devices and store every message durably until the receiver acknowledges it.
ARCHITECTURE / DATA FLOW DIAGRAM
photo, 2 MBAshaphonegroup of 200WhatsApp servers1 hi, 2 how are youBenphone

Why Mediated Store-and-Forward Replaces Peer-to-Peer on Mobile

Direct phone-to-phone TCP communication fails across mobile networks because carrier-grade NAT (CGNAT) hides client IP addresses, cellular handoffs continuously rotate ephemeral endpoints, and mobile operating systems suspend background apps or lose signal entirely on flights and dead batteries. Placing a server tier between Asha and Ben decouples sender availability from receiver reachability: Asha uploads a message once over her active connection, and the server either pushes it immediately down Ben's open socket or holds it safely until Ben reconnects, propagating Sent, Delivered, and Read state transitions back to Asha.

  • Scale Amplification: 2,000,000,000 active users exchange ~100,000,000,000 messages/day (~1.16M msgs/s steady state), turning socket state management and cross-server routing into the primary bottleneck.
  • Ordering & Idempotency: If Asha sends "hi" followed by "how are you" over a flaky 4G link that triggers retries, Ben must observe each message exactly once and strictly in causal send order.
  • Workload Heterogeneity: 2 MB photos (20,000x larger than a 100-byte text message) and N-member group chats require isolated storage and fan-out paths so they never stall 1-to-1 text sockets.

Transient Delivery Relay vs. Permanent Cloud Archive

A foundational architectural decision separates WhatsApp from Slack or Telegram cloud chats: WhatsApp servers act strictly as a transient delivery relay rather than a permanent history database. Once Ben's phone acknowledges receipt of a message, the server deletes its copy immediately—bounding server-side message retention to a 30-day offline window, minimizing storage footprint by orders of magnitude, and aligning naturally with device-only End-to-End Encryption (E2EE) where servers hold zero plaintext or long-term message archives.

Architectural DimensionNaive / Stateless ApproachWhatsApp Core Principle
Client-server transportStateless HTTP polling drains radio battery and adds multi-second lagLong-lived bidirectional WebSocket per online phone with tiny heartbeats
Server storage lifecycleRetain all historical messages forever (multi-PB/year growth)Store-until-acked in replicated Mnesia; evict on ACK or after 30-day offline TTL
Binary media attachmentsStream megabyte blobs over chat WebSockets (head-of-line blocking)Upload encrypted blob via HTTPS to Blob Store + CDN; send tiny file_id on socket
Group chat deliverySynchronous N-way loop inside sender's chat serverSingle append to per-group Kafka log + asynchronous Group Handler fan-out
Interview Signal: Clarify history retention in the first 2 minutes of an interview: transient store-and-forward (delete on ACK) keeps working sets tiny enough for low-latency replicated RAM/SSD stores like Mnesia, whereas multi-device permanent history requires wide-column stores like Cassandra/ScyllaDB partitioned by (chat_id, bucket_id).
SECTION 02 OF 5

2. Requirements of WhatsApp's Design

🔒 PRO SECTION
Key Takeaway: Text payloads require modest bandwidth (926 Mbps) and bounded 30-day offline storage (300 TB), whereas holding 2 billion open connections drives server fleet sizing (~200 high-concurrency gateways) under a strict CP-over-AP ordering guarantee.

Section 1 + Checkpoint Quiz #1 are unlocked free outside the paywall. Unlock all architecture slides, QPS & sharding trade-off tables, and all 80 narrated HD video lessons with Full Access — or inspect our sample payment system lesson first.

SECTION 03 OF 5

3. High-Level Design of WhatsApp

🔒 PRO SECTION
Key Takeaway: Keep chat gateways ultra-lean by limiting them to WebSocket framing and 1-hop Redis session routing, while offloading offline queues to Mnesia, group fan-out to Kafka + Group Handlers, and binary media to an Asset Service + Blob Store + CDN.

Section 1 + Checkpoint Quiz #1 are unlocked free outside the paywall. Unlock all architecture slides, QPS & sharding trade-off tables, and all 80 narrated HD video lessons with Full Access — or inspect our sample payment system lesson first.

SECTION 04 OF 5

4. Detailed Design of WhatsApp

🔒 PRO SECTION
Key Takeaway: Full-duplex WebSockets eliminate idle polling overhead, hop-by-hop acknowledgements with sequence numbers drive deterministic 1/2/blue receipt ticks, content-hashed CDN blobs isolate media load, and Kafka partitions serialize group fan-out without breaking E2EE.

Section 1 + Checkpoint Quiz #1 are unlocked free outside the paywall. Unlock all architecture slides, QPS & sharding trade-off tables, and all 80 narrated HD video lessons with Full Access — or inspect our sample payment system lesson first.

SECTION 05 OF 5

5. Evaluation of WhatsApp's Design

🔒 PRO SECTION
Key Takeaway: Choosing consistency over availability guarantees in-order, loss-free conversations even during gateway crashes, provided clients mitigate multi-million-socket reconnect storms with randomized exponential backoff.

Section 1 + Checkpoint Quiz #1 are unlocked free outside the paywall. Unlock all architecture slides, QPS & sharding trade-off tables, and all 80 narrated HD video lessons with Full Access — or inspect our sample payment system lesson first.

ACTIVE RECALL & TRADE-OFF PROBES

System Design Checkpoint Quizzes (1)

CHECKPOINT QUIZ #1

In "System Design: WhatsApp" (Transient Delivery Relay vs. Permanent Cloud Archive), how does a production-grade design handle "Server storage lifecycle" (WhatsApp Core Principle)?