jargon

Comparison

Long pollingvsWebSocket

Long polling

the client makes a request and you hold it open for thirty seconds, only answering when something actually happens.

Holding a request open until data is available or a timeout expires, then having the client immediately reconnect. It gives near-real-time delivery over plain HTTP with no protocol upgrade. It consumes a connection and often a server thread per waiting client, which is why it scales far better on async runtimes than on thread-per-request ones.

ClientServerrequestreply when readyrequest againreply
Full entry →

WebSocket

you upgrade the connection once and then push messages in both directions without a new request each time.

A persistent, bidirectional connection over a single upgraded HTTP connection. It is the right choice when the server must push frequently or the client must send continuously. It costs you statefulness: connections pin clients to instances, so deploys, scaling and load balancing all become harder than with stateless requests.

ClientServeropen oncemessagemessagemessage
Full entry →

Related comparisons