Long polling is a process where browser sends a request to server. Server holds that request and keep the request thread open until any data is available. Once data is available at server, it sends the response to the browser and closes request thread. Once browser receive the response, it initiates another request and the process continues. This is called long polling in web development.
We can use long polling when we want to get real time updates from server. For example, to display live cricket score, to display latest share prices etc.
- We can get real time updates from server.
- Easy to implement.
- It consumes server resources and increases load on server if incoming request are large.
- Applications with intense calculation and business processing may cause high latency time.
Long Polling is an old picture, Now you can achieve the same thing in a better way using Web Sockets technology.