Long Polling
Async CommunicationThe client asks for updates, but the server holds the request open until there's data (or a timeout) instead of replying immediately — a simple, widely-compatible way to approximate push.
Long polling is a workaround for HTTP's request/response nature that predates WebSockets and SSE. The client sends a normal HTTP request, but instead of replying immediately, the server holds the connection open until either new data is available or a timeout elapses — then it responds (with data, or empty on timeout) and the client immediately issues a new request. From the client's perspective this feels close to real-time push, while from the network's perspective it's still plain HTTP request/response, so it works through virtually any proxy, firewall, or load balancer that doesn't understand WebSockets.
How it connects
Long Polling as the source, with the components it typically interacts with.
- → Load Balancer: Held long-poll requests still consume a connection slot on the LB/server, so capacity planning must account for concurrently outstanding polls.
- → WebSockets: Long polling is most often deployed as the automatic fallback when a WebSocket upgrade handshake fails or is blocked.
- → Server-Sent Events (SSE): SSE and long polling solve the same one-way-push problem; SSE is preferred when streaming HTTP responses are supported, long polling when they aren't.