Try
↑ ↓ move↵ openesc close
In this lesson · topic 3 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 3

Break the network and watch delivery

8 min read

What the lab runs

Thirty users each have an inbox with its own sequence numbers. Ten messages a tick go to random users. A message is sent over the user’s connection. If the delivery is lost, or the acknowledgement is lost, the server waits three ticks and sends again.

Each gateway can crash. Its users drop off, then reconnect to a live gateway after four ticks. Some users also go offline on their own for a few ticks. A message for an offline user waits and is sent when they return.

The client has two modes. Show on arrival displays each message as it lands. Hold for sequence keeps a message back until every lower number has been shown. A duplicate check, when on, drops a message whose number the client already has.

The model has one inbox per user, not one sequence per two-person conversation. The behaviour that matters is the same.

Predict before you press play

You turn on hold for sequence and keep 10 percent loss. What changes on the screen?

tick 60gateways up 3 of 4users online 15 of 30shown on arrival

What the screens show

sent
600
shown
565
out of order
3.9%
duplicates shown
0

Messages carry a sequence number per recipient. Out of order means a message appeared after one that was sent later.

Delivery work

waiting for first delivery
35
resends
127
gateway crashes
1
median / 99th percentile delay
0 / 18 ticks

A message that gets no acknowledgement is sent again. Messages for offline users wait in their inbox.

Messages not yet delivered, last 150 ticks
Messages not yet delivered, last 150 ticks. Text version available below the chart.01325385013160recent ticksmessages

Full-page version with guided experiments: Chat delivery lab.

Things to try

  1. Set loss, crashes and offline users to 0.
  2. Keep 10 percent loss and show on arrival.
  3. Hold for sequence.
  4. Turn the duplicate check off.
  5. Raise users going offline to 5 percent a tick.
  6. Set gateway crashes to 2 percent a tick with no loss.

The full-page lab has a guided experiment for each of these.

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