Try
↑ ↓ move↵ openesc close

Interview prep / Chat system

Junior · Chat system · System design interview question

How does a chat server deliver a message to a user who is not making a request?

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

A strong answer

The user keeps a persistent connection open to the server, usually a WebSocket. The server writes the message to that connection when it arrives.

A normal request and response cannot do this, because the client has to ask first. The server therefore needs to track which connection belongs to which user.

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