r/programming • • Oct 10 '26

Stop reaching for WebSockets by default: WebSockets vs SSE vs Long Polling

https://medium.com/@anirbansingha20/websockets-vs-long-polling-vs-server-sent-events-fa9bc1644cb8

Real time communication isn't one size fits all. A common mistake in system design is picking WebSockets when all you really needed was server-to-client streaming.

I wrote a short 3 minute architectural comparison of the trade offs here:https://medium.com/@anirbansingha20/websockets-vs-long-polling-vs-server-sent-events-fa9bc1644cb8

What do you usually reach for first when building real time features ?

236 Upvotes

92 comments sorted by

View all comments

Show parent comment

1

u/robert_7524 Oct 19 '26

In browser JS, Ping/Pong frames aren't exposed: the browser answers server pings, but your app can't schedule them. SSE can keep an idle stream alive with comment lines.