Jump to content

AJAX Push (Long Polling best?)


echofool

Recommended Posts

So whilst making a ajax feature, i was told using a fake server push effect was the best way to allow more users without server getting too many connections. Whilst it makes sense as its one connection per user rather than many every X amount of seconds in the traditional AJAX method i researched it up and asked around. And came accross a JS professional (freelancer which has very strong ratings) happened to argue that it was infact not the best idea and infact possibly worse.Here was his arguements :

Long-polling requires a while loop to run until the script is closed/killed after it reaches maximum execution time (usually 30-60 seconds). While this loop is, well, looping, it's going to keep a MySQL connection alive, until it dies or is killed off. Which means you will only be able to have a maximum number of users on at one time (anywhere between 100-200, depending on the size/beefiness of your server).Whereas, placing single calls (and not using long-polling) simply "leases" a slot from MySQL, until the script is done running (usually less than a second), and then frees the slot. Allowing more than the maximum amount of concurrent connections to MySQL (anywhere between 250-500 or more, depending on each person's activity).Though, either one can still cause conflicts (enough people to place 100-200 calls at one time, causing MySQL to fill up momentarily), using a package method (sending non-vital information back to the server as a "Package", will help reduce the amount of calls made to the backend. Also, using a queue for communication between the front-end and back-end of the script, will allow for you to check whether or not the command or packet was received and handled by the server, long-polling allows the same, but it's pointless as the MySQL slots are never released until the script dies.
So what is your thoughts on this ... has any one ever done calculations to see which one really does seem best ? I can understand his arguements but also the against for the fake server push method also. Im torn between which one is really best, so thought this probably the best place to ask on thoughts on this so...what are your thoughts?
Link to comment
Share on other sites

The thing is... "best" for what?For action intensive applications like fighting and racing games, using the so called "long polling" technique is basically the only way. Anything less increases the possiblity of "lagging" dramatically.For not so action intensive applications like chats, collaboration apps and turn based games, in which a short lag is acceptable, normal polling dramatically increases the amount of possible active users, making it the best for this scenario.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...