ajax push server

风格不统一 提交于 2020-01-11 14:20:35

问题


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.


回答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 :

  • Is there some way to PUSH data from web server to browser?
  • Online tutorials for implementing comets (server push)
  • Using comet with PHP?
  • Problem of choosing comet server
  • Comet & PHP: How to use Comet with a PHP Chat System ?


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 :

  • Choosing and deploying a comet server.



回答2:


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




回答3:


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



来源:https://stackoverflow.com/questions/1407624/ajax-push-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!