HTTP Polling, HTTP Long Polling & WebSockets - DevDummy


Views | Thoughts | Concepts | Techniques

Tuesday, December 26, 2017

HTTP Polling, HTTP Long Polling & WebSockets

HTTP Polling

HTTP polling is the process of looking for the server by client in pre-defined time intervals to fetch up-to-date information if available. In HTTP polling, client send a request to a server. Then the server responds with any new messages. If there are no new messages available, the server responds with an empty or pre-agreed format. This flow is repeated by the configured polling interval. HTTP polling generates a significant network overhead in the system as it requires the repetition of the headers in each request.

Therefore, HTTP polling performs comparatively well, if the update receiving frequency is fixed. If the update receiving frequency is high or the update receipt is random or non-predictable, HTTP polling may lead to a communication overhead. Hence, the main drawback of the HTTP polling is sending number of unnecessary requests to the server even there are no new updates to fetch.

HTTP Long Polling

HTTP long polling is a variation of polling technique defined to overcome the above-mentioned drawbacks of simple polling. It is defined to efficiently handle the data transmission between the server and the client. The difference of the long polling is that, it doesn’t send an empty response immediately, when there are no new messages. Instead of that, the server waits for a new message to respond or the request is timed out. 
This offers more efficient solution to the polling, especially when there are less new messages in the system, reducing the number of client requests. Again, if connection timeouts are appearing beyond response, still HTTP long polling is not very advantageous. Hence, HTTP long polling has not resolved all the drawbacks appeared by HTTP polling.


WebSockets protocol was introduced as an extension, to enhance the client-server communication with several value additions. In real-time data exchange, WebSockets performs well with less communication overhead, providing efficient and stateful communication between client and the server. WebSockets protocol allows to maintain long term TCP socket connections between clients and servers. More importantly web sockets enable the messages to be instant delivered with a negligible overhead to the system, in real time, bi-directionally and full duplex manner. WebSockets exhibit a unique feature of traversing through firewall and proxies. It can detect the presence of proxy server and automatically sets up a tunnel to pass through the proxy.
Especially the web browsers can be take the advantage of full duplex mode to send data in either direction at the same time. Also, the WebSockets provide a significant reduction of network congestion and overheads than a regular duplex system which maintain two connections with polling, by operating thought a single socket over the web.

With the enhanced capabilities of the WebSockets protocol, it is often suitable for network application frameworks to provide more of consistency, allowing massive scalability on real time platforms. Also, it has been emerging as a very reliable, highly performing, real-time ready and promising protocol for inter-node communication as well, making it a reliable methodology for cluster management.


  1. I. Fette and A. Melnikov, “The Websocket Protocol,” 2011.
  2. Hanson J. What is HTTP Long Polling. Pubhub. December. 2014.
  3. I. Hickson, “The Websocket API,” W3C candidate recommendation, Dec. 2011;


No comments:

Post a Comment