Server-Sent Events vs WebSockets: Choosing a Transport by Failure Mode
If you are developing a live-event dashboard or feed, choosing the right transport protocol for pushing updates to the browser can make or break the user experience. Many developers start…

What is in this piece
What survives a disconnect
Server-Sent Events (SSE) offer a very different connection model than WebSockets. When the browser loses the SSE stream, it can use the server-provided retry field to wait before reconnecting. This is specified in milliseconds and must be an integer. If the server omits the retry value, the browser will wait for about 3 seconds before attempting to reconnect.
The advantage in handling a temporary drop is that when a server-sent event connection is re-established, the browser can send a Last-Event-ID header. This tells the server to resume the event stream from the point where the connection was cut, avoiding duplicate or missing messages.
WebSocket connections in contrast lack automatic reconnection or message replay. If a WebSocket gets interrupted and the client does not have its own reconnect logic, the socket is closed and the connection is lost without any automatic recovery.
Connection budgets and tab pressure
Some of the biggest surprises come in connection budgets with server-sent events over HTTP/1.1. In this configuration, the connection-opening partitions are per-origin and per-browsing session. an authoritative source on tab counts and origins so this matches browsers' per-tab partition On one browser, engineers may find only 2 to 6 open server-sent event connections allowed. After that, all further attempts will get rejected. Each event source counts against this budget.
The problem can be especially bad with multiple tabs. Imagine if a live dashboard open in 10 tabs; statement on per-tab origin capacities for SSL in various browsers — it could starve itself out of connection budget before loading the first event.
HTTP/2 offers a way out of this bottleneck. In this mode, server-sent events use multiplexed streams over a single connection instead of multiple separate HTTP/1.1 keep-alives. A common characterization of the default is a practical limit of around 100 concurrent streams per connection. That adds up to a much more generous capacity for live dashboards. authoritative confirmation from browsers on the exact HTTP/2 stream counts and how this specification would trade off between protocols.
What the network stack sees
As much as HTTP/2 eases the burden on open connections in server-sent events, it cannot make a one-way transport bidirectionally interactive like a persistent WebSocket.
Server-sent events are a specialized adaptation of HTTP. The HTTP server can push live events to the client without a dedicated outbound channel. But this is a one-way path. The client cannot send reliable messages to the server on that stream over HTTP, as WebSockets allow.clarification on whether an underlying compatibility is detected, so that simple HTTP proxies would allow server-sent events to operate with WebSocket behavior
In WebSocket API, after the initial HTTP handshake a separate upgrade is negotiated and the sockets can transmit either direction over the dedicated TCP connection. permission from networking authorities to mention HTTPS port 443 This does incur some complexity in the network stack. Network intermediaries and lightweight proxies may need special attention with WebSocket-protocol messages to avoid them getting automatically rejected.
One more detail to emphasize for WebSocket and server-sent events: Client-side reconnection is automatic on server-sent events, with the server responsibility to leverage this with Last-Event-ID. But clients are on their own to decide a policy for transparent WebSocket reconnection. github repository or check assertion by browser standard to confirm WebSocket reconnect's actual absence
When polling still matters
Apart from server-sent events and WebSockets, many teams still credibly deploy applications that use polling. Polling works by having the client repeatedly use an HTTP request to ask the server if there are any new updates. In practice, there are usually two forms: simple and long.
In simple polling, the client just makes a new request at an interval, say every 10 seconds, even if the server has no updates. This is tolerant to the worst network conditions, so can work over some carrier-grade cellular connections.
Long polling keeps the connection open from client to server until the server has something to send or the client times out, saves the server-based flush, then the client just submits another request. But neither of these create a dedicated stream of the sort that server-sent events or WebSockets enable. The connection overhead in HTTP is unavoidable.
The actual bidirectional cases
There is one obvious mismatch for every benefit that server-sent events offer: the total silence of the client on the full-duplex WebSocket. It is hard to imagine the case in which the server-end needs to be the sole speaker and the client can afford to skip built-in resume after a failure, but there are indeed scenarios when live answers are needed.
Bidirectional testing between the server's push LAN and the client’s pull LAN might not be enough to justify WebSockets. Imagine detection-heavy diagnostics in IoT: if the on-board sensors need to diagnose which sensor is offline, they will need WebSockets.
In conversational interfaces—live chat, Q&A, or interactive collaboration—there will not always be an active speaker. And the interaction is not free of risks: temporarily flaky mobile edge portals can cut the test stream. Ultimately, SSE-plus-gets would not update the interaction in enough time to accomplish tasks.
If live updates must maintain real-time consistency without divergence, then this is a true use-cases for WebSocket.
Operational tradeoffs on mobile
Server-sent events have one more nuance in mobile environments. Modern cellular “always connected” endpoints are never always connected. The probe drop due to carrier noise and connectivity oscillation are as predictable as radio sleep and captive-portal boots. With long-running / closed, the browser's SSE retry can sometimes miss a flurry of events. WebSocket clients' reconnect behavior is more defined, but with enough retries, they will start to boost short-term battery consumption.
In dev tools, you can sometimes see the browser stall for up to 30 seconds during a transiently failed network assumption. And mobile thresholds can be tuned to just 15s split between server-sent events and WebSockets. Security layers like captive portals are thoroughly chatty.
The bottom line often asked is this: Server-sent events are easy to use and add simple load at scale, especially over HTTP/2 multiplexing.
WebSockets can backfill bilaterally—with a WebSocket's support for operations such as real-time file sharing. Because in browser theory, the amount of notifications required by the server is actually the price ceiling for a server-sent events endpoint.
- 01Engineering Practice
The Structured Logging Fields That Shorten an Incident
When a cloud-native application goes down, the production log is where on-call engineers turn to answer three crucial questions: which specific request failed, in which specific deployment…
- 02Engineering Practice
The Smallest Feature Flag Service You Can Build Yourself
You would rightly think that a feature flag system is mainly a dashboard. a vendor or standards definition stating which part is foundational But the key architecture boundary lies…

