tags:

views:

287

answers:

2

Aside from the obvious heavy load on the server, is it bad to have several concurrent AJAX polls going on at the same time? Or is there even a limit as to what a browser/server can handle?

Example (all AJAX polling)..

  • Function A is on a 3 second interval pulling for new message for a global chat system (like Facebook/MySpace).

  • Function B is on a 2 second interval for pulling updates and what actions to show the user (such as in an online poker application).

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

+3  A: 

Browsers used to have a limit of 4 (or in really old cases 2) concurrent connections per domain. Most modern browsers have upped this to 6 or 8 (based on my own testing and some supporting reading).

So long-polling connections can eat up those slots in the browser and potentially prevent other things from downloading as quickly.

Otherwise, it could be a bandwidth hog for people on slow connections (dial-up or cellular networks).

There may be other drawbacks, but those are two big ones I see.

Gabriel Hurley
A: 

You should never need more than two active AJAX connections simultaneously. Either you do long-polling, e.g the server responds with headers but then send the entity body when there is data to deliver.

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

Ernelli