Sunday, 15 July 2012

Using comet with PHP? -



Using comet with PHP? -

i thinking of implementing real time chat using php backend, ran across comment on site discussing comet:

my understanding php terrible language comet, because comet requires maintain persistent connection open each browser client. using mod_php means tying apache kid full-time each client doesn’t scale @ all. people know doing comet stuff using twisted python designed handle hundreds or thousands of simultaneous connections.

is true? or can configured around?

agreeing/expanding has been said, don't think fastcgi solve problem.

apache

each request apache utilize 1 worker thread until request completes, may long time comet requests.

this article on ajaxian mentions using comet on apache, , difficult. problem isn't specific php, , applies back-end cgi module may want utilize on apache.

the suggested solution utilize 'event' mpm module changes way requests dispatched worker threads.

this mpm tries prepare 'keep live problem' in http. after client completes first request, client can maintain connection open, , send farther requests using same socket. can save signifigant overhead in creating tcp connections. however, apache traditionally keeps entire kid process/thread waiting info client, brings own disadvantages. solve problem, mpm uses dedicated thread handle both listening sockets, , sockets in maintain live state.

unfortunately, doesn't work either, because 'snooze' after request complete, waiting new request client.

php

now, considering other side of problem, if resolve issue holding 1 thread per comet request, still need 1 php thread per request - why fastcgi won't help.

you need continuations allow comet requests resumed when event triggered observed. afaik, isn't that's possible in php. i've seen in java - see apache tomcat server.

edit:

there's article here using load balancer (haproxy) allow run both apache server , comet-enabled server (e.g. jetty, tomcat java) on port 80 of same server.

php comet

No comments:

Post a Comment