How do you keep chat messages in order?
Sketch your own answer first, then compare it with the one below.
A strong answer
Give each message a sequence number per conversation, assigned by the server when it accepts the message. Clients sort by that number.
Do not order by client clocks. They disagree. A single writer per conversation gives a simple total order.
Sources
- Leslie Lamport (1978). Time, clocks, and the ordering of events in a distributed system.