I am planning about a chat system for my website. I am thinking about doing ajax pushing. The client will initiate a connection to the server by calling chat.php. chat.php will do an infinite loop(30 sec). On getting a new message it will return the print the message to the client and exits the connection. The ajax script on getting a responseText calls chat.php once again. My question is the scalability of such a system(php driven COMET) for 500 concurrent chat processes on a shared hosting package.
-
http://stackoverflow.com/questions/1633793/implement-comet-with-php-driven-website – zod Jan 20 '12 at 20:37
-
4That's like asking "Can I haul a load with a car?". How big of a load, how big of a car? If your shared hosting package is an 8088-4.77Mhz with 640k of ram, then I'm going to say "No, it won't scale". – Marc B Jan 20 '12 at 20:38
-
A 30 sec loop is not an infinite loop... ;-) – netcoder Jan 20 '12 at 20:42
-
^Dats Y i mentiond 'infinite loop(30sec)' ;) – Killswitch Jan 21 '12 at 09:07
1 Answers
My question is the scalability of such a system(php driven COMET) for 500 concurrent chat processes on a shared hosting package.
You won't be able to get away with this on shared hosting. Chances are that the Apache instance on the server is configured with a much lower concurrent connection limit. Even if it wasn't, having five hundred active PHP instances on a shared hosting account is going to get noticed and will severely degrade the experience for everyone else on the shared machine.
PHP is probably not the best tool for this job. If you want to do it with PHP, you're going to need a VPS or dedicated hardware. Honestly, even if you don't use PHP, you're going to need a VPS or dedicated hardware to implement a solution that better fits the problem (like a background process to serve the chat requests directly, something you can't do on shared hosting).

- 50,943
- 13
- 104
- 142
-
I would be glad if you could give an elaborated solution on "a background process to serve the chat requests directly"-that you just mentioned... – Killswitch Jan 21 '12 at 09:19
-
Look at Python's Twisted library and Node.js as good comet solutions. In both cases, they'd run in the background and serve requests instead of going through a web server process. – Charles Jan 21 '12 at 18:46