Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

solution for COMET and PHP

Tags:

php

comet

Is there a real solution for COMET AND PHP combination? Basically, I've come to a point that I need to update a user home page periodically whenever there is new data in the database. As far as I understand, I need to open a persistent connection between my server and my clients browsers to update the contents of their home page as soon as new info. available without dedicating a lot of resources but I had no luck finding anything clear about this issue. I read many articles suggests that PHP is not a good language to implement COMET. My web application is completely programmed in PHP and I don't want to learn another language but if I'm forced to, Would you suggest a good language to start with? Do you think that I can program an interface just to handle this issue?

Thanks in advance.

like image 281
codemaker Avatar asked Oct 25 '22 23:10

codemaker


2 Answers

The times I've heard people say that PHP was not well suited for COMET (like you said yourself) was because of the way webservers and PHP work -- mostly, because there is one process per page, which means if you want 200 users connected to your server, you'll need 200 processes (which can quickly become a problem for a couple of hundred more users).

Maybe a solution to that problem would be to use nginx_http_push_module ?

I've not tried it (yet ?), but it might be just what we need...

like image 186
Pascal MARTIN Avatar answered Nov 15 '22 05:11

Pascal MARTIN


I was working on a school project and ran into the exact same problem. Because each PHP process has so much memory overhead, it's impossible to support to many connections per box. It was at this point I decided to switch to using BOSH and XMPP. This is a rather new "wave" of technology but there is already quite a few libraries to help you on your way. I would suggest using Strophe and XMPPHP. Then your clients can connect to a BOSH server (I'm using Openfire) and that can scale to thousands of active connections per server.

like image 34
Kendall Hopkins Avatar answered Nov 15 '22 07:11

Kendall Hopkins