简体   繁体   English

PHP与彗星彗星

[英]php comet with quercus

如果我用php编写Comet push,但通过quercus在java服务器上使用此代码,是否可以解决apache遇到的每个请求一个过程的问题,并且可以很好地扩展使用我的聊天功能的许多用户?

Yes , Quercus solves the one process per request Apache bottleneck. 是的 ,Quercus解决了每个请求Apache瓶颈的一个过程。 However, you need to understand the possible bottlenecks of the JVM. 但是,您需要了解JVM的可能瓶颈。 In my opinion, though, you should write the service or app in C/C++ using something like libevent, in Erlang, in Google Go, or simply as a Java servlet simply for portability's sake. 但是,在我看来,您应该使用libevent之类的东西在C / C ++中使用Erevent,Google Go编写该服务或应用程序,或者仅仅是出于可移植性的目的而将其编写为Java servlet。

Well, Quercus runs on the (J)VM so it can run with other code that can start threads. 好吧,Quercus在(J)VM上运行,因此它可以与其他可以启动线程的代码一起运行。 But why do you need threads to do chat? 但是,为什么需要线程进行聊天? You simply set the timeout on a vanilla PHP request to 0 (no timeout) and wait for there to be something to send back to the user. 您只需将原始PHP请求的超时设置为0(无超时),然后等待将某些内容发送回用户。

That something else will be in response to someone else's request (ie A says "hello" which interrupts B's wait for something to happen). 会有其他事情响应别人的请求(即,A说“你好”,这打扰了B等待某事发生)。 That doesn't require multithreading. 那不需要多线程。

Also you could keep using Apache/PHP and do the above and instead connect to a Java (or other) service via something like XML RPC, which could wait forever. 另外,您可以继续使用Apache / PHP并执行上述操作,而是通过XML RPC之类的东西连接到Java(或其他)服务,这可能会永远等待。 That server could do run multiple threads or do whatever it needs to. 该服务器可以运行多个线程,也可以执行所需的任何操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM