2

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?

John Gardeniers
  • 27,262
  • 12
  • 53
  • 108
tftd
  • 1,480
  • 7
  • 24
  • 38

2 Answers2

2

I would personally recommend Apache using mpm_worker with FastCGI PHP, eAccelerator, and possibly disk caching via mod_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 to mpm_worker, FastCGI PHP and mod_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 to readfile() a cached minified JS file is far slower than letting Apache with mpm_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 :-)

Josh
  • 9,001
  • 27
  • 78
  • 124
  • Thank you for sharing this information! I'll most certainly try adding the suggested modules. Only parts of my php code is cacheable but all of the images/css/javascripts are not changed frequently (or maybe wont be changed for a long time) so I'll give it a shot! I'm sorry I can't give yet points but when I'm able I'll come back and add :) – tftd Jan 12 '11 at 01:45
1

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.

mattdm
  • 6,550
  • 1
  • 25
  • 48
  • Yes I thought that too. I'm influenced by Java and that's why my code is 98% static OOP. And because I'm doing this for the first time in php I wasn't quite sure if this wouldn't brake it. – tftd Jan 12 '11 at 01:40