Thursday, September 28th, 2006
COMET with PHP
<p>Manuel Lemos has written a post aboutthe details and challenges of an AJAX COMET implementation in PHP.
The article describes an approach used to implement highly responsive AJAX applications using the COMET approach, and how it can be implemented in PHP.
It also discusses how HTTP compression and chunking affect AJAX response delays, as well aspects that may influence the choice between Apache 1.3.x with mod_gzip versus Apache 2.x with mod_deflate for AJAX COMET applications.
Community Question: Are any of the PHPers out there doing COMET? If so, do you have anything to add about the experience?
Related Content:











My understanding is that PHP is a terrible language for Comet, because Comet requires you to keep a persistent connection open to each browser client. Using mod_php this means tying up an Apache child full-time for each client which doesn’t scale at all. The people I know doing Comet stuff are mostly using Twisted Python which is designed to handle hundreds or thousands of simultaneous connections.
Another language to look at is Ruby. Using Ruby’s Event Machine you can scale to loads of connections easily as it has a non blocking io. This is the method the new version of juggernaut (Comet for ruby on rails) is using.
Simon is partially right in that PHP doesn’t easily let you do Comet. mod_php doesn’t let you keep connections open for extremely long periods of time (because that violates PHP’s “shared-nothing” architecture that allows it to scale well). If you’re going to do Comet in PHP you have to cheat and either do polling with a very short interval or create an XMLHttpRequest connection that is long-lived. Check out this info at AjaxPatterns.org for more information on this idea by a guy way better at explaining it than me.
This approach has nothing to do with COMET – i was very disappointed reading this one on dzone yesterday. Firing a request on multiple IFRAMES – well… COMET is something else. Nice idea though but mischosen topic!
Mario, there seems to be a misundersanding. This implementation does not fire a request on multiple iframes. It just a single request to a single iframe that may a stream of multiple chunks of Javascript code to execute customizable actions on the browser side upon events that happen on the server side. The chunks of Javascript code are sent independently of each other to the browser using a single connection. The article explains why it is important to assure HTTP 1.1 chunked responses are used, so the Javascript chunks are flushed to the browser right after each event occurs on the server side.
Simon, the problem of scalability is not so much on PHP but rather on the Web server mode that you use to run PHP. If you use Apache with pre-forked processes, it consumes much more memory than using Apache or some other Web server in multithreading mode. PHP core extensions and the execution engine (Zend engine) are thread-safe. What is not thread safe are some extensions and libraries that may be needed to run your scripts. Another alternative to run PHP with a multithreaded Web server, is FastCGI. It may not be as fast as mod_php, but it may handle much more simultaneous connections with the same amount of memory.
scat slave
girl squirt uncut white boy cock mature latina
sperm shack
amateur blowjobs french orals cumtv
I’ve written something about it at this blog, but I call it LazyHttp, I think the “Comet Washing Brand” is just overdoing it… ;)
ç§ã«ã¾ã ç§ãŒãれを決ã—ã¦â€¦.èžã‹ãªã‹ã£ãŸã‚ãªãŸã®DVDãŒã‚る何もã®ãŸã‚ã«ã¾ã åƒã„ã¦http://www.canttakeitanymore.comã§å®Ÿè³ªã®ä»•事をã‚ã¨ã§å¾—ãªã•ã„
interseting blog
Has this changed yet? What are my options in implementing Comet with php?