Stop Defaulting to WebSockets: When to Use SSE or Long Polling Instead
How Long Polling, Server-Sent Events, and WebSockets Actually Work, and When Each Is the Right Choice for Your System
The web was built on a simple model.
A client sends a request, the server sends a response, and the exchange ends. This request-response model works beautifully for loading pages and fetching data, because the client always initiates and the server always replies.
Modern applications broke this model.
A chat app needs to show a message the instant it arrives.
A live sports app needs to update the score the moment it changes.
A trading platform needs to push prices continuously, and a collaborative document needs to reflect another person’s edits in real time. In all of these, the server has new information and needs to deliver it to the client without the client asking first.
This is the core challenge of real-time communication on the web.
HTTP does not let a server push data to a client on its own, so engineers developed patterns to work around this limitation.
The three most important are long polling, server-sent events, and WebSockets, and they represent three different points on a spectrum of capability and complexity.
Choosing among them is a common system design decision, and the wrong choice leads to either unnecessary complexity or insufficient capability.
A team that reaches for WebSockets when a simpler pattern would do takes on operational burden it does not need, while a team that forces a simple pattern onto a demanding workload ends up fighting its limits.
This article explains all three patterns in depth, how each works, what each costs, and when each is the right choice. It includes a side-by-side comparison, a decision framework you can follow, and the scaling considerations that matter in a real system. The goal is to let you choose the right real-time pattern with confidence rather than by default.
Why HTTP Needs These Patterns
To understand the three patterns, it helps to see clearly why the basic web model falls short for real-time updates.
In the standard model, the client must initiate every exchange. The server cannot speak unless spoken to. So if the server learns something new, such as a message arriving for a user, it has no way to deliver it until the client makes a request. The information sits and waits.
The naive workaround is short polling, where the client repeatedly asks the server on a fixed interval, such as every few seconds, whether there is anything new. This technically works, but it is wasteful and slow.
Most requests return nothing, consuming bandwidth and server resources for no result, and any new data waits up to a full interval before the client learns about it. Short polling is the baseline that the three real patterns improve upon.
The three patterns each solve the server-push problem differently. Long polling makes the waiting smarter. Server-sent events open a one-way stream from server to client.
WebSockets open a two-way channel where either side can speak freely. Understanding how each achieves server push, and what it gives up to do so, is the heart of the decision.
Long Polling: The Universal Fallback
Long polling is the simplest step up from short polling, and it remains the most broadly compatible of the three patterns.
The mechanism is a small but clever change. Instead of the server immediately responding to a client’s request with “nothing new,” it holds the request open, keeping the connection waiting until it actually has data to send or until a timeout is reached.
When new data arrives, the server responds right away, and the moment the client receives that response, it immediately sends a new request to wait again.
The result is a continuous cycle of held-open requests, so the client almost always has a pending request ready to receive the next update.
This delivers a real improvement over short polling. Updates arrive close to the moment they happen rather than waiting for the next interval, and the wasteful empty responses are largely eliminated, since the server only responds when there is something to say.
The biggest advantage of long polling is universal compatibility. It is just ordinary HTTP, so it works everywhere, through every proxy, firewall, and old browser, with no special protocol or infrastructure. When nothing else is supported or the environment is constrained, long polling almost always works.
Its disadvantages come from the fact that it is still a series of separate request-response cycles. Each update involves the overhead of a full HTTP exchange, including headers, which is heavier than a true streaming connection.
There is also a brief gap between when the server responds and when the client re-establishes its waiting request, during which new messages can be missed unless the server buffers them and the client tracks what it has seen. Holding many open requests also consumes server resources, and the pattern is effectively one-directional for real-time purposes, since client-to-server communication happens through separate ordinary requests.
Long polling fits situations where updates are relatively infrequent, where maximum compatibility matters, or where the simplicity of plain HTTP outweighs the need for the lowest latency.
A notification system that delivers occasional alerts, or a feature that must work in a restrictive corporate network, is a reasonable fit. It is the dependable fallback when the more capable patterns are not available or not warranted.
Server-Sent Events: One-Way Streaming Done Simply
Server-sent events, or SSE, is a standard built specifically for streaming updates from the server to the client over a single long-lived connection. It is often the best choice for one-way real-time data, and it is underused relative to how well it fits many problems.
The mechanism is elegant.
The client opens a single HTTP connection and the server keeps it open, streaming a continuous sequence of text events down that one connection as they occur.
Keep reading with a 7-day free trial
Subscribe to System Design Nuggets to keep reading this post and get 7 days of free access to the full post archives.



