
- A single chat server can keep on the order of
~2 millionpersistent 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.
- The sender’s client end-to-end encrypts the message and transmits it over the persistent TCP connection to its attached chat server.
- 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.
- 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.

- 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.
- 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.

- 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.

- 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.
Delivery flow summary
Further reading and references
- Erlang: https://www.erlang.org/
- FreeBSD: https://www.freebsd.org/
- Apple Push Notification Service (APNs): https://developer.apple.com/documentation/usernotifications
- Firebase Cloud Messaging (FCM): https://firebase.google.com/docs/cloud-messaging
- WhatsApp engineering (historical scaling posts): https://engineering.fb.com/ (search for WhatsApp scaling)