Try
↑ ↓ move↵ openesc close

Interview prep / Chat system

Junior · Chat system · System design interview question

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

Learn it by running it

The design a chat system lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

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