Search code examples
websocketstreamingcometserver-sent-eventshttp2

Which communication technology should I use for pushing data stream to the website users


I'm building a website where I want to allow users to subscribe to various realtime data streams. They will subscribe to few streams and it will be pushing the data back as long as they are connected. The question is, which technology is more suitable for this: Server Send Evenets, Websockets, HTTP/2, Comet? What should I use for achieving the best results? I aim for quite big amount of users with this. Will appreciate for answers pointing me in the best direction here.


Solution

  • This was already discussed before both when debating the role of AJAX (great for CRUD, not so much when polling) and when comparing Websocket performance vs. AJAX performance (Websockets are always faster where live updates are concerned).

    Comet and SSE are interesting flavors for HTTP polling, but is the end they only mitigate the side effects to a degree, while Websockets (often coupled with the publish–subscribe pattern using Redis or something similar) are the best tool for the job.