Skip to main content
How does WhatsApp deliver ~100 billion messages per day with low latency and minimal resource use? At a high level: each phone maintains a persistent TCP connection to a chat server. Those chat servers run on FreeBSD (chosen for strong networking performance) and implement messaging logic in Erlang (a language built for massive concurrency and fault tolerance). This combination lets each server handle millions of simultaneous persistent connections.
A simple diagram showing a phone connected over a TCP connection to a chat server. Inside the server are FreeBSD and Erlang components, with the caption "Good at networking."
Key benefits of this architecture:
  • A single chat server can keep on the order of ~2 million persistent TCP connections open.
  • In-memory state and Erlang’s concurrency model enable fast routing and low-latency delivery.
  • FreeBSD provides a high-performance networking stack for many concurrent sockets.
Message delivery sequence (typical path)
  1. The sender’s client end-to-end encrypts the message and transmits it over the persistent TCP connection to its attached chat server.
  2. The sender’s chat server consults an in-memory routing table that maps each user to the chat server instance where they’re currently connected.
  3. If the recipient is online, the sender’s chat server forwards the encrypted payload directly to the recipient’s chat server, which then delivers it down the recipient’s TCP connection.
A schematic diagram showing two phones labeled "You" and "Friend" connected to different chat servers (Chat Server 1 and Chat Server 200) with arrows indicating inter-server communication. Below is a routing table that maps users (You, Friend, Jack) to their respective chat server IDs.
Ephemerality and encryption
  • Delivered messages are not permanently stored on WhatsApp servers. Once a delivered message reaches the recipient’s device, servers typically delete the message payload.
  • Because WhatsApp uses end-to-end encryption, servers only route encrypted blobs and do not have access to message plaintext or user content.
WhatsApp uses end-to-end encryption, so servers forward encrypted payloads and cannot read message contents. Servers only need metadata to route and deliver messages.
Handling offline recipients If a recipient is offline (no active TCP connection), WhatsApp uses an offline storage tier for short-term retention and attempts to wake the device via push notifications:
  • The sender’s chat server writes the encrypted message to the offline store (in-memory or short-lived storage).
  • The server triggers a push notification through Apple Push Notification Service (APNs) or Firebase Cloud Messaging (FCM) to prompt the recipient device to reconnect.
  • When the recipient reconnects, the message is delivered and then removed from the offline store.
A dark schematic diagram of a chat system showing two phones labeled "You" and "Friend" connected to separate chat servers with arrows into an "Offline Storage Tier." The diagram also shows components labeled "In Memory" and "Push Notification" (with an Apple icon) and the friend's phone displaying "No internet."
Group messaging and server-side fan-out Group messages increase delivery load because a single outbound message must reach every group member. WhatsApp optimizes this by fanning out on the server side:
  • The sender uploads one encrypted copy of the message to its connected chat server.
  • That server replicates (forwards) the message to the chat servers where each group member is connected, using the in-memory routing table.
  • Destination servers deliver the message to connected devices. For offline group members, the message is written to the offline storage tier for later delivery.
A dark-themed network diagram showing a central smartphone with arrows to four orange-outlined server boxes labeled "Server 1", "Server 57", "Server 200" and "Server 312". Below are a row of smaller smartphone icons labeled "Group Members."
Why this scales
  • Persistent TCP connections reduce connection overhead and allow servers to push messages immediately.
  • An in-memory routing table provides fast, constant-time lookups for where to forward messages.
  • Erlang’s lightweight processes and fault-tolerant design enable efficient handling of millions of concurrent sessions.
  • Short-lived offline storage and push notifications minimize long-term storage requirements and maximize delivery speed.
Key components at a glance Delivery flow summary Further reading and references This architecture — persistent connections, in-memory routing, Erlang on FreeBSD, short-term offline storage, and server-side fan-out — is how WhatsApp scales to deliver tens or hundreds of billions of messages per day while keeping latency low and resource usage efficient.

Watch Video