Try
↑ ↓ move↵ openesc close

Interview prep / Chat system

Senior · Chat system · System design interview question

How would you design presence, and what would you not guarantee?

Sketch your own answer first, then compare it with the one below.

A strong answer

Use a heartbeat with an expiry. A connected client pings every so often, and the server records online with a lifetime a little longer than the interval. When pings stop, the entry expires and the user shows as offline.

The expiry is a failure detector, so it trades speed against false offline marks. Do not broadcast every change to every contact. Send presence only for open conversations, and only on change, and accept delays of seconds.

Presence can be late and approximate. Messages and their order cannot.

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