Try
↑ ↓ move↵ openesc close
In this lesson · topic 1 of 7
  1. 1. A message that must arrive once, in order
  2. 2. Requirements, numbers, API and data model
  3. 3. Break the network and watch delivery
  4. 4. Loss, resends and the order they create
  5. 5. Gateways, connections and crashes
  6. 6. Receipts, offline inboxes and presence
  7. 7. The chat system in review

Topic 1

A message that must arrive once, in order

4 min read

Four things go wrong

A chat message looks simple. One person sends text and another reads it. Four things get in the way.

  • The recipient has no request to answer. The server must push, so it needs an open connection to every online user.
  • Messages travel on different paths and take different times. Two messages sent in order can arrive out of order.
  • Networks drop packets. A message that is not confirmed must be sent again, and a resend can arrive twice.
  • People go offline. The message must wait, and reach them in order when they return.

What the lab shows

The lab sends 5000 messagesmeasured to 30 users through 4 gateway servers. The network drops 10 percent of packets, gateways crash, and users go offline now and then.

When the screen shows messages in the order they arrive, 5.7 percentmeasured appeared out of order. With no packet loss the figure was 0.0 percentmeasured. The server resent messages 1163 timesmeasured.

The fixes are small and old. A sequence number per conversation fixes order. An acknowledgement and a resend fix loss. The same sequence number fixes duplicates. This lesson walks the whole design around them.

Predict first

The server resends a message because its acknowledgement was lost. The first copy had already arrived. What does the user see without any duplicate check?

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms