I'm writing a PHP site that's expected to get about 200-300 concurrent users browsing it. When initializing the application will load about 30 PHP classes, some 10 maybe 15 images and a couple of css files.
So my question is, what else can I do (except optimizing my code and using apc/eaccelerator for PHP) to get as close as possible to those numbers of concurrent users?
Currently we haven't chosen a server for the site to be hosted on but most probably it'll be a VPS Dual core + 2 or maybe 4GB RAM. Is it possible for such a server to handle that load? Also how could I test it myself and be sure that it'll be able to handle it?
I would personally recommend Apache using
mpm_worker
with FastCGI PHP, eAccelerator, and possibly disk caching viamod_disk_cache
, depending on your PHP application. If you use PHP to generate sttaic, cacheable files like images, JavaScript or CSS, or if your content is cacheable, you may notice a huge performance boost.We switched from Apache's
mpm_prefork
+mod_php
tompm_worker
, FastCGI PHP andmod_disk_cache
, and we saw dramatic improvements in speed. One reason is, we use PHP to minify JS and CSS files, and even just calling PHP toreadfile()
a cached minified JS file is far slower than letting Apache withmpm_worker
serve that file from a disk cache.Many people tout lighttpd above Apache at all costs saying Apache is bloated and slow. I've used lighttpd before and it was pretty slick, but in my experience Apache can be tuned for extreme performance, and the
mpm_worker
module gives you the same basic threading concept that lighttpd is based on.Re: RAM, get as much as you can! If you can afford 4GB, do it. You'll be glad you did.
For performance testing, there's lots of great tools out there but I find that the apacvhe benchmark tool that comes with Apache is a fast and easy way to test for performance. The specifics of how it should be used warrants a separate question :-)
Unless your PHP code is really awful, the answer is that any of those solutions should handle the load. You should go with whatever is most familiar to you and the easiest for you to configure and manage.