AJAX side-by-side polling

Besides the obvious heavy load on the server, is it bad to simultaneously conduct multiple simultaneous AJAX polls? Or is there a limit as to what the browser / server can handle?

Example (all AJAX polls) ..

  • Function A is at a 3-second interval, pulling out a new message for the global chat system (e.g. Facebook / MySpace).

  • Function B is at a 2-second interval for pulling out updates and what actions to show the user (for example, in online poker).

  • Function C is on the 4 second interal, but also pulls a new message for a separate messaging system.

+4
source share
3 answers

Browsers had a limit of 4 (or in really old cases 2) simultaneous connections to the domain. Most modern browsers have increased this to 6 or 8 (based on my own testing and some supporting readings).

Thus, polling connections can eat these slots in a browser and potentially prevent other things from downloading quickly.

Otherwise, it may be bandwidth for people with slow connections (dial-up or cellular networks).

There may be other flaws, but I see two big ones.

+3
source

You do not need more than two active AJAX connections at the same time. Or you do a long poll, for example, the server responds with headers, and then sends the body of the object when there is data for delivery.

If you run the polling scheme as the one you described above with A, B, C, you can do this with one AJAX thread that alternates between three requests, but with a timeout value set to the next request interval. You create an imaginary timeline in which you distribute your requests to A, B, and C using a single AJAX thread.

0
source

I found that some mobile devices (like iPad) clamp more than one pending xhr request.

0
source

All Articles