← Lessons

quiz vs the machine

Gold1420

System Design

The WhatsApp Messaging Scale

Persistent connections and store and forward deliver messages to offline phones.

5 min read · core · beat Gold to climb

Always connected, sometimes offline

WhatsApp keeps a persistent connection from each phone to a gateway so messages arrive instantly. But phones go offline constantly, so the system must hold messages until the recipient reconnects.

Store and forward

When a recipient is offline, the server stores the message and forwards it on reconnect. Once delivered and acknowledged, the server can drop its copy.

  • Each phone holds a long lived connection to a gateway
  • If the recipient is online, the message is relayed immediately
  • If offline, it is queued until reconnect, then delivered

Delivery acknowledgements

The familiar ticks are acknowledgements. A message moves from sent to delivered to read, each step driven by an ack flowing back through the system. The server retains the message only until a delivered ack arrives.

Reliability comes from queuing for offline users and freeing storage only after an acknowledged delivery.

Key idea

Hold a persistent connection per device, store and forward messages for offline recipients, and use acknowledgements to know when it is safe to drop a stored message.

Check yourself

Answer to earn rating on the learn ladder.

1. What does store and forward solve for WhatsApp?

2. When can the server safely drop its stored copy of a message?