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.
- stackoverflow.com/questions/1633793/…zod– zod2012-01-20 20:37:29 +00:00Commented Jan 20, 2012 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– Marc B2012-01-20 20:38:42 +00:00Commented Jan 20, 2012 at 20:38
- A 30 sec loop is not an infinite loop... ;-)netcoder– netcoder2012-01-20 20:42:21 +00:00Commented Jan 20, 2012 at 20:42
- ^Dats Y i mentiond 'infinite loop(30sec)' ;)Killswitch– Killswitch2012-01-21 09:07:23 +00:00Commented Jan 21, 2012 at 9:07
1 Answer
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).