5

SSE is based on HTTP protocol, and ws requires one time HTTP upgrade.

For a small user base, I understand, WebSocket is way too good over SSE.

I am worried about how much difference will it be for 10,000 user chat system. Here the major concern is:

For WebSocket, I will have to run a loop for 10,000 connections to emit a message every time a new message is received.

For SSE, there is no loop, but a single server-sent event that will stream data to 10,000 users.

To me, Looking on paper it looks like SSE is best for such a large number, especially when numbers of connected clients will keep increasing to 20,000, 100,000. There is no 10,000 value loop running for every new message.

Is it practically true as well? I tried searching quite some performance benchmark for WebSocket vs SSE but can't find any.

Please confirm, if SSE will have better performance and low server resource utilization over WebSocket for emitting / streaming messages to such a large no. of users?

John Cargo
  • 1,758
  • 1
  • 28
  • 57
  • Does this answer your question? [WebSockets vs. Server-Sent events/EventSource](https://stackoverflow.com/questions/5195452/websockets-vs-server-sent-events-eventsource) – Scott Stensland Aug 26 '20 at 10:46
  • 1
    @ScottStensland - I already read the information shared in your URL and it has the only definition, meaning, and advantages one over other. I am already aware of the information. But my concern here is the "Performance Gap" for one over other on the server especially for large numbers where WebSocket starts falling slowly with growing numbers. For example: "10K users chat room group" – John Cargo Aug 26 '20 at 10:59
  • @JohnCargo, I'm exploring SSE and Websocket. Did you find the answer? It would be helpful for the community if you could share it with us. – Sanjay Sharma Nov 26 '21 at 05:55
  • @SanjaySharma - This can be helpful ~ https://stackoverflow.com/a/5326159/2819754 – John Cargo Nov 26 '21 at 11:46

0 Answers0