In this lesson · topic 1 of 7
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