长轮询用PHP在Apache [英] Long Polling with PHP on Apache

查看:125
本文介绍了长轮询用PHP在Apache的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望我能解释这不够好。我的工作创造一个 PHP库来处理PHP通过在的面向对象的方式Ajax请求。我目前正在琢磨一个很好的方式来实现长轮询解决方案,但很好奇的东西。

Hopefully I can explain this well enough. I am working on creating a PHP library to handle ajax requests through PHP in an object oriented manner. I am currently pondering a good way to implement a long polling solution but am curious about something.

Apache不处理保持多个连接开得很好。线程,每个请求的模式使得Apache的长轮询非常低效。使用服务器,如nginx的和的lighttpd库处理这些线程更好的话,我打算实施优化,可以从一个单一的函数调用特定的服务器不同的功能。在Apache中的情况下,这恰好持有巨大的市场份额为PHP应用程序,我需要一个更好的解决方案。

Apache doesn't handle keeping multiple connections open very well. The thread-per-request model makes Apache highly inefficient for long polling. Using server's such as nginx and lighttpd handle these threads much better so in the library, I plan on implementing different functions optimized to the specific servers available from a single function call. In the case of Apache, which happens to hold an enormous market share for PHP applications, I need a better solution.

有没有一种方法,可保持/暂停传入的请求并继续处理其他请求,直到我准备重新激活它?

Is there a way to place an incoming request on hold/pause and continue processing other requests until I am ready to reactivate it?

我不知道如果是有道理的,或者如果我甚至在正确的轨道。什么是这样的建议对PHP长轮询Apache服务器上可能的解决方案?

I'm not sure if that makes sense or if I am even on the right track. What is a possible solution that SO recommends for long polling in PHP on an Apache server?

推荐答案

这听起来像是延续。您可以绝对不是在PHP中做到这一点,任何优雅的方式。如果你想这样做,你最好的机会是保存当前的状态,在这样的,你可以从你的时候加载状态,你离开的地方恢复方法写code。

This sounds like continuations. You can definitely not do this in PHP, in any elegant way. If you want to do this, your best chance would be to save the current state, and write the code in such a way that you can resume from where you left off when you load the state.

这篇关于长轮询用PHP在Apache的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆