Daily iOS
iOS system design

Ordering in a real-time news feed

A real-time social news feed receives incremental WebSocket events and an initial REST list. To make sure no events get lost during the initial sync, in what order do you wire up the two channels?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

Open the WebSocket first and start buffering events, then fetch the snapshot over REST, and apply in order only the buffered events whose sequence number is higher than the one in the snapshot, so nothing that happened between snapshot creation and socket connection gets lost.

Share a question