How to Design WhatsApp: Requirements and High-Level Architecture

System design of a WhatsApp-like chat app: requirements, scale estimates, WebSocket gateways, chat service, message store, presence and push notifications.

Published November 27, 2026

Designing a messaging app like WhatsApp is one of the most popular system design problems because it combines real-time networking, huge scale, strict delivery guarantees and privacy. This first article in the series sets the requirements, estimates the scale and lays out the high-level architecture. Later articles zoom into connections, delivery receipts, group chat, storage, offline delivery, encryption, media and presence.

The concept

The core functional requirements are one-to-one messaging, group messaging, delivery and read receipts, online presence and last-seen, offline message delivery and push notifications, and media sharing. Non-functional requirements dominate: messages to online users should arrive in well under a second, no acknowledged message may be lost, messages within a conversation must stay in order, and the service must work over flaky mobile networks for billions of users.

The architecture is built around long-lived connections. Each phone keeps a persistent connection (WebSocket or a custom TCP protocol) to a gateway server. Gateways are thin: they authenticate, hold connections and forward frames. Behind them, a chat service routes messages to the recipient's gateway if they are online, persists them, and triggers push notifications if they are offline. A session registry records which gateway each user is connected to.

Requirements and scale

RequirementTarget
Users2B+ registered, ~500M DAU (assumption for design)
Messages~40/user/day → 20B/day ≈ 230K/s average, ~1M/s peak
LatencyOnline-to-online delivery < 500 ms p99
DurabilityNo loss after the server acknowledges ("sent" tick)
OrderingPer conversation, as sent by each sender
Group sizeUp to 1,024 members
PrivacyEnd-to-end encryption; server cannot read content

High-level architecture

Mobile clientspersistent WebSocket / MQTT-style TCPLoad balancer (L4)sticky TCP, TLSGateway servershold millions of connectionsChat serviceroute, sequence, persistSession registryuser → gateway (Redis)Message store + queueCassandra / HBase, KafkaPush serviceAPNs / FCM for offline users
The main components of a chat backend.

How a message travels

AliceGateway AChat serviceGateway BBobsend msg (seq 41)forwardpersist + assign idack → ✓ sentroute (Bob online)deliverack → ✓✓ delivered
The happy path for a one-to-one message.

Storage estimate

With an average encrypted message of about 200 bytes plus metadata, 20 billion messages per day is roughly 4-6 TB per day before replication. WhatsApp historically deleted messages from servers once delivered, keeping only undelivered messages, which keeps storage small. If your design keeps message history server-side (like Telegram or Slack), you need petabyte-scale storage partitioned by conversation.

Practical examples

Minimal message envelope

The server routes on metadata; the body is ciphertext it cannot read.

{
  "type": "msg",
  "client_msg_id": "c1f9-4b7e-...",   // dedupe on retries
  "conversation_id": "u42:u77",
  "sender_id": 42,
  "recipient_ids": [77],
  "client_ts": 1764238512345,
  "ciphertext": "base64...",
  "media": null
}

Session registry in Redis

Each gateway records which users it holds; the chat service looks them up.

HSET session:77 gateway gw-17 conn_id 9f3a since 1764238400
EXPIRE session:77 90          # refreshed by heartbeats
HGET session:77 gateway       # → gw-17

Back-of-the-envelope numbers

Connections drive gateway count.

concurrent_connections = 200_000_000     # 40% of DAU online at peak
per_gateway = 1_000_000                  # tuned Linux/Erlang servers can hold ~1-2M
print(concurrent_connections // per_gateway, "gateways (+ headroom)")   # 200

Common mistakes

  • Polling for new messages over HTTP instead of keeping a persistent connection.
  • Making gateways stateful beyond the connection, so a gateway crash loses messages.
  • Ignoring ordering and deduplication when mobile clients retry over flaky networks.
  • Designing global total ordering of messages, which is unnecessary and very expensive.
  • Forgetting the offline path: push notifications and stored messages.

Key takeaways

  • Persistent connections to thin gateway servers are the foundation.
  • A chat service routes, sequences and persists; a registry maps users to gateways.
  • Acknowledge to the sender only after the message is durably stored.
  • Offline delivery, receipts, groups, media and encryption build on this core.

FAQ

What protocol does WhatsApp use?

WhatsApp historically used a customised version of XMPP over a persistent TCP connection, with its own binary encoding. Many modern designs use WebSockets or MQTT.

Why was Erlang famous at WhatsApp?

Erlang's lightweight processes made it practical to hold millions of concurrent connections per server with a small engineering team.

Is this design the same as Slack or Discord?

The connection and routing layers are similar. Slack and Discord keep full server-side history and search, so their storage and indexing layers are much heavier.

More Architecture articles