WebSockets vs. Long-Polling vs. TCP Scalability / Ease of Use

I am writing a backend for a Java-based mobile web application, and I was wondering how scalability and ease of use depend on the advantages and disadvantages associated with using WebSockets or Long-Polling solutions such as comet. Another option will also implement my own solution using TCP. From what I read, it seems that you need to run Long-poll solutions on dedicated servers, as they do not work well in Tomcat / Jetty when you start working with a large number of users. WebSockets seems to be scalable. Are there any flaws in working with comet websites or should I just resort to my own solution using TCP connections? I am looking for an option that uses the least traffic.

+4
source share
1 answer

I suppose it depends on your convenience and tolerance of learning new things, but, of course, along the way of using WebSocket APIs for communication or even SSE is better than the traditional long polling / comet solution for many reasons - one that you mentioned - scalability, but also to use bandwidth and delay. It is also important to understand that WebSocket refers to the Internet, which is TCP for a desktop computer, for example. socket. In a desktop solution, you do not have to encode TCP; you use a client library that supports the transport protocol, such as STOMP or XMPP over TCP. You do the same when using WebSocket, choose a server for communication, for example. XMPP server and XMPP client library for communicating with the server via WebSockets.

You can see our example here , and we docs you can read here .

The thing to note is browser adoption of HTML5 WebSocket - currently in Chrome and Safari, and soon in FF and Opera. We turned to this, but if you plan to create your own server, you will have to create a solution for older versions.

+5
source

All Articles