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.