In response to the on going flame war pertaining to the stability and usability of Apache 2 in comparison to Apache 1 I've decided to conduct a series of benchmarks to try to determine exactly how the two Apaches compare. The purpose of the test was to determine which server is faster at serving static HTML pages, who's real-time compression implementation is better and of course which is more suited for running PHP applications. The full details of the test are available below, but here is a quick summary of the results.
1) Apache 2 is about 4% faster then Apache 1 at serving static pages.
2) Apache 2's mod_deflate is over 60 percent faster then Apache 1's mod_gzip at real time compression of static HTML pages.
3) Serving PHP via Apache 2 is 27 percent slower then via Apache 1 DSO and 31 percent slower then Apache 1 static.
How the test was conducted?
For the purpose of the test I've used clean installations of PHP 4.3.10 compiled with the following common flags "--disable-cgi --disable-cli --without-pear". The sapi options ranged from --with-apxs (Apache 1 DSO), --with-apxs2 (Apache 2 DSO apache2handler), --with-apache (Apache 1 static).
The Apache1 was compiled with --enable-module=so and --enable-module=rewrite, --activate-module=src/modules/php4/libphp4.a was added for static build PHP build. Apache 2 was compiled with --with-mpm=prefork --enable-rewrite --enable-so --enable-deflate. During the compilation of all software -O2 optimization flag was used.
Apache configuration used are the stock configs from the regular build, with modifications to add PHP and mod_gzip (Apache 1) support and making Apache 2 bind to port 8080.
The "victim" server was Celeron 1ghz with 768 megs of ram running Linux 2.6.8-rc2. For each test a total of 10 runs were performed each making 10000 requests, concurrency level ranging from 10 to 100 requests. The test software used is ab (Apache Bench) revision 1.73.
Quite frankly, given the current state of PHP it really doesnt surprise me that it was not faster on apache 2. Thats like saying "well I built my GUI application with intel SSE extensions and then am surprised that it isnt properly optimized to run on an athlon platform"
It would be nice to get PHP and its associated libraries threadsafe, setup a test with multi-threaded MPMs in apache and then see a real comparison.
Even better, it would be nice to be able to skip all the hard development work, test, get the results, and know whether or not it would be worth putting in the time to do the work... but thats having my cake and eating it too.
I run many production web servers running debian gnu linux, kernel 2.6.15 and 2.6.17 with roughly equal mixes of Apache 1.3 and 2.0 and PHP4.3 / 5.0 respectively. Apache2 with PHP5 and MySQL5 with mod_deflate is around 10% faster overall than the Apache 1.3 PHP 4.3 boxes (Same Hardware, Base OS and System Configs).