Daily iOS
Networking

REST snapshot plus WebSocket delta consistency

This is an exchange app's order book and ticker screen. The design fetches the current snapshot over REST first and then applies only the changes (deltas) that arrive over WebSocket, but now and then the order book on screen drifts from reality. In what order, and by what rules, do you combine the snapshot and the delta stream so consistency doesn't break?

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

Subscribe to the socket first and buffer the deltas, then fetch the snapshot, then apply in order only the deltas whose sequence is after the snapshot's. If you fetch the snapshot first and subscribe afterward, you miss the changes in between.

Share a question