DevPrep

All topics › Networking & APIs

Polling, long polling, SSE or WebSocket: how do you get real-time data?

Middle PRO

The gist

The update delivery mechanism is chosen along three axes: direction (server → client only, or both ways), frequency and required latency, and cost for the battery and the server. For rare events polling or push is enough, for a stream of server events — SSE, for interactive two-way exchange — WebSocket.

The rest of this answer, with code and interview follow-ups, is in the DevPrep app.

Read the full answer in DevPrep

Practice this before your interview

DevPrep turns these answers into one-minute challenges: what does this code print, find the bug, mock interviews. One challenge a day.

Get DevPrep on the App Store