3

I'm developing an app where two or more separate clients will exchange specific information via a server transfer in real time by all clients invoking the process at approximately the same time (within less than 2 seconds or so of each other).

The flow for each client: Jquery Ajax Request that includes data to post > Apache/PHP adds posted data then loops through database query until 2+ results are found coresponding to the total record set of all the clients > query result sent back to requestor JSON encoded

I'm at a loss on how to construct an ajax request that will feed this flow and a PHP/mySQL server side script that will consume and loop until the entire query data set is available.

Options I'm considering include, but are not limited to:

1) Long Polling - but I read it's expensive in terms of resources and not advised with Apache/PHP 2) JS/jQuery client side retry loops until good response - but seems to also be server resource hog due to repetitive connections

I expect to have a very large user base that will place demands on the server environment well beyond this process. What would be the most efficient method to use and what would be the basic corresponding jQuery/PHP that would make it happen?

Inator
  • 994
  • 2
  • 14
  • 33

1 Answers1

3

yes polling is too resource intensive. so use websockets or better use libraries built using websockets. pusher is one.

and in open source, there are juggernaut and faye. These are libraries for pushing real time data to clients(so as is your requirement)

hitesh israni
  • 1,742
  • 4
  • 25
  • 48