0

Alright, I recently wrote a ajax push script which had php on the backend sleeping while waiting for someone to make an update. However, the sleeping processes took up a lot of cpu. Any ideas on how I can prevent this? I am guessing I will have to either find a program which can do the sleeping with threads or write my own in python or c++ which I am not very familiar with. I am using ajax push for a browser based game so people can play it in real time but I think if I get too many sleeping processes on the backend it would overload the server.

David
  • 710
  • 2
  • 14
  • 27
  • Two examples available at http://www.udaparts.com/document/Tutorial/httppush.htm and http://www.udaparts.com/document/Tutorial/slpush.htm –  Sep 03 '11 at 21:35
  • PHP is not the best language for this, by far. Use Node.js, pyhon/twisted or or something like that. – c69 Oct 04 '11 at 05:19
  • Yes, php is not the best but I have a great working daemon now with no memory leaks in php; however; a slight issue with multiple tabs in the same browser; made as a different ticket. As for Node.js, I have tried to install node.js 3 different times; twice on centos and once on ubuntu which was suppose to be ready for node.js and it still did not install right; tried several tutorials. As for python/twisted; that is the route I am looking into. – David Oct 04 '11 at 12:14

3 Answers3

1

If I understand correctly, you want some kind of long-polling stuff -- you should search for the term "comet".

For instance, here are a couple of posts that might interest you :


Still, one might say that PHP, because of its non-threaded model, I suppose, is not the best language/technology for that kind of stuff... And maybe you'll end up looking to another technology for that part of your site...

For instance, you can take a look at :

Community
  • 1
  • 1
Pascal MARTIN
  • 374,560
  • 73
  • 631
  • 650
0

some links about reverse http: reverse http 1 making-real-time-web-real-time reverse http 2 rest-requires-asynchronous-notification

andres descalzo
  • 14,451
  • 12
  • 60
  • 105
0

After much research last night, I found this as the answer for the server side. Then write a php script for the client side. Then have ajax call the client which calls the server. Only problem is some of the extensions have to be manually installed.

http://php-mag.net/itr/online_artikel/psecom,id,484,nodeid,114.html

David
  • 710
  • 2
  • 14
  • 27