What are the pros and cons of a long survey versus a regular survey?

I have a webpage that I have to check on the server for updates every second. Updates can be relatively frequent or infrequent. At the same time, there may be many web clients checking the server for updates. This can be either an AJAX request every second, or a "long poll" that emulates a click on the server. Which method would I like to use and why? It seems that the overhead of initiating an HTTP connection every second may make the long polling method preferred. On the other hand, there is probably a limit on the number of concurrent connections that the server can support. Some comparisons of these methods would be useful for me to decide where to go.

+4
source share
1 answer

It depends on your web server. Newer web servers are being created that understand the AJAX / Comet style and make long-term polling very efficient. See Mongrel2 for an example.

You can also consider regular polling, but make it dynamic. Without knowing my domain, I cannot make a specific recommendation. But imagine in a chat application. Instead of polling every second, I can wait a bit after sending a chat message to give another person time. Then check a few times a little, and if I still do nothing, slow down (as the other person may disappear). I can have polling intervals from 1 second to 30 seconds depending on the situation.

All this needs to be tested for sensation, but on average I could make it feel like the 1st survey, when on average it looks more like 20.

+5
source

All Articles