SSE or WebSockets for one-way updates on a small VPS?

November 18, 2026 4 answers
Asked by Rovdeli.8k

For server-to-client updates on a VPS with 2 GB of RAM and one vCPU, would SSE or WebSockets handle more concurrent connections? What should guide the choice?

Answers

_v28~tumblerjay.6

For one-way updates, I would start with SSE. It uses HTTP and the browser's EventSource API reconnects automatically after a dropped connection. WebSockets make more sense if clients also need to send messages over the same connection.

That doesn't mean SSE automatically supports more clients. Both keep long-lived connections open, so the server framework, memory use, connection limits and event rate all matter. Test the actual stack before putting a number on capacity.

Reply to this answer
_m4.zorvexa

HTTP/2 can make a difference here. An SSE stream can share an existing HTTP/2 connection with other requests, rather than requiring a separate TCP connection for each stream. A conventional WebSocket connection uses a separate connection and an upgrade handshake.

But multiplexing helps most when a client has multiple streams or requests to share. It doesn't eliminate the cost of serving lots of separate clients. Socket buffers, per-connection memory and whatever work happens when you publish an update still need measuring.

Reply to this answer
Kora

Watch the proxy setup. Nginx response buffering can delay SSE events, and an idle read timeout can drop the stream. Disable buffering for the SSE route and send periodic heartbeat comments so quiet connections stay active.

Becks:

Also check the timeouts on any other proxy or load balancer in the path. The heartbeat interval needs to fit within those limits too.

Reply to this answer
Jex

Don't treat the protocol choice as a scaling plan. SSE connections still have to live somewhere, and adding servers means deciding how updates reach the instance holding each client connection. WebSockets have that same basic problem.

For the VPS, load test both idle connections and the expected update rate. Watch memory, CPU and connection limits. A test that only opens connections won't tell you what happens when messages are sent to all of them.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions