Lazyweb Request: Why would PHP be *faster* than HTML?
With the help of the great guys at Slicehost.com, I am attempting to run my benchmark series on a virtual private server, to compare with EC2. However, I'm seeing a very strange result for the baselines: a PHP page delivers more requests-per-second than a static HTML page.
The OS is a stock Ubuntu 8.10 installation; you can see the setup steps here.
The virtual private server has 2 gigs of RAM, and is on a box by itself, so there is no other external activity to skew the results.
ab -c 10 -t 60 http://localhost/ on each of two files: index.html, which has only the static text "hello world"; and index.php, which has only the code
<?php echo 'hello world'; ?>.
Here are the results without APC, averaged over 5 one-minute runs:
index.html : 7067.57 req/sec index.php : 7484.57 req/sec # faster???
Here are the results with APC, averaged over 5 one-minute runs:
index.html : 7013.50 req/sec index.php : 8041.06 req/sec # faster???
I haven't seen this behavior on EC2. I'm not complaining, but it does seem unintuitive; invoking the PHP interpreter should be more expensive than just delivering a static HTML file. Does anyone have ideas as to why this might be happening?
UPDATE: With the help of Paul Reinheimer, we appear to have found the culprit: the
ab tool itself seems to be at fault. Running similar tests by hand with
siege returns much more reasonable and expected numbers (~4000 req/sec for HTML, ~3200 for PHP). I'm going to re-work the test scripts to use
siege later and report back. Thanks to everyone who provided suggestions, and special thanks to Paul Reinheimer for working through it with me today.