WhatsApp 00:00:01 A phone registers its new connection Asha wants to send Lee a message while both are moving between networks. Build a WhatsApp-style messaging system as a design exercise. The transport and capacity choices here illustrate one implementation. In this design the phone opens an authenticated persistent connection. Passing data through the new connection does not automatically prove the handset is still reachable. Signed, not expired, account active. strangers must not hold sockets. Device to server 42, connection 7. others can route to it, and an old connection cannot erase a newer one. A ping every 30 seconds keeps it alive. 90 seconds of silence ends it. A connection registry should give each device session a fresh identity. A late disconnect from an old session must not erase the route that just replaced it. 00:00:52 Separate accepted from delivered Asha presses Send. Give the message a stable client-generated identifier and commit the service's durable message record before reporting its first acceptance milestone to her. The message goes over the open connection with an ID made on the phone. no new connection, and retries keep the ID. In the illustrated durability policy the log commits the message with redundancy across zones and returns its position. The registry says chat server 2, and that server's lease is alive. The cursor moves to 120. A receipt goes to Asha by the same road. The next milestone belongs to Lee's device. A gateway accepting bytes and a recipient device durably accepting the message are different observations. 00:01:39 Keep the message when Lee goes offline The gateway has no live route to Lee. A delivery worker can preserve the pending message and optionally nudge a disconnected device, without treating a push notification as proof of delivery. Asha has one tick. The worker does not know yet whether Lee is there. If it had an entry, the worker would hand over to the chat server at once, as in the online path. Any chat server will do. The phone sends cursor 119. The cursor moves, the entries are cleared and the senders get two ticks. On reconnection, authorize the device, inspect its durable progress, and replay missing messages. If the history retention window elapsed, the protocol needs an explicit resynchronization path. 00:02:25 Receipts move in one direction A delayed delivered receipt may arrive after a later read receipt. If the interface merely uses the last event it received, a message can appear to go backwards. Asha writes a message. The log has it on two zones. One tick. Lee's device stored it. Lee may not have looked. An old delivered event arrives. Its rank is lower, so nothing changes. Keep per-device progress and a defined aggregation policy for a multi-device account. Receipt semantics should tell Asha what was actually observed, including any privacy choices about reading receipts. 00:03:02 A lost acknowledgement becomes a repeated send Asha's first submission commits, but its reply disappears. She retries with the same message identifier. Silent success and a lost request sound identical from her phone. Asha sends with ID 7f9c. Only after the commit. the record must mean done. After 5 seconds the phone sends again, with the same ID. If a short-lived deduplication cache forgets the key, a durable uniqueness check can still protect the log. The receiving device also deduplicates by stable message identity. Use durable message identity at the server and tolerate repeated delivery at the device. Transport encryption is another layer: carry ciphertext on the server paths when the product promises end-to-end encryption.