Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are Websockets faster than Server Sent Events

Hi I currently came accross this paper and I can't figure out why Server-Sent Events are slower for pushing data from a server to a client.

I can see the point that SSE are slower for bidirectional communication like a chat applikation because of the HTTP overhead for XHR.

like image 791
webpapaya Avatar asked Jan 21 '26 23:01

webpapaya


1 Answers

I think there are two effects combining here to cause the claim that WebSockets are "faster" than SSE.

Effect 1: SSE has a Lower Payload to Message Ratio As you noted, in general, the overhead of HTTP requests/responses is larger, compared to a more compact payload and careful protocol design with WebSockets, in a bi-directional communication pattern.

Effect 2: SSE can involve Session Reconnections As @alexsergeyev points out correctly, SSE sessions can reconnect, but in most modern browsers that simply means SSE sessions do get re-created using pooled TCP connections, so the effect on

Combining these two effects, and defining throughput in bytes/second as the metric, I hope we can see that even for uni-directional server to client communication, throughput is better for WebSockets due to both these effects.

As far as I know, as the adoption of WebSocket-aware intermediaries takes off, the role for SSE will be reduced as time goes on. Right now, if you rely on HTTP for your security story, you might choose SSE unless you have hard-real-time requirements. If you do, the Kaazing Enterprise WebSocket gateway has built-in SSO integration for most security systems.

like image 174
nowucca Avatar answered Jan 24 '26 17:01

nowucca



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!