{
    "href": "/post/2009/02/19/lazyweb-request-why-would-php-be-faster-than-html/",
    "relId": "2009/02/19/lazyweb-request-why-would-php-be-faster-than-html",
    "title": "Lazyweb Request: Why would PHP be *faster* than HTML?",
    "author": "pmjones",
    "markup": "html",
    "tags": [
        {
            "href": "/tag/benchmarks/",
            "relId": "benchmarks",
            "title": "Benchmarks",
            "author": null,
            "created": null,
            "updated": [],
            "markup": "markdown"
        },
        {
            "href": "/tag/php/",
            "relId": "php",
            "title": "PHP",
            "author": null,
            "created": null,
            "updated": [],
            "markup": "markdown"
        }
    ],
    "created": "2009-02-19 16:55:26 UTC",
    "updated": [
        "2009-02-19 16:55:26 UTC"
    ],
    "html": "<p>With the help of the great guys at <a href=\"http://slicehost.com\">Slicehost.com</a>, I am attempting to run my <a href=\"http://paul-m-jones.com/?p=315\">benchmark series</a> on a virtual private server, to compare with EC2. However, I'm seeing a very strange result for the baselines: a PHP page delivers <strong>more</strong> requests-per-second than a static HTML page.</p>\n<p>The OS is a stock Ubuntu 8.10 installation; you can see the setup steps <a href=\"http://code.google.com/p/web-framework-benchmarks/wiki/ServerSetup\">here</a>.</p>\n<p>The virtual private server has 2 gigs of RAM, and is on a box <em>by itself</em>, so there is no other external activity to skew the results.</p>\n<p>I ran <code>ab -c 10 -t 60 http://localhost/</code> on each of two files: index.html, which has only the static text \"hello world\"; and index.php, which has only the code <code>&lt;?php echo 'hello world'; ?&gt;</code>.</p>\n<p>Here are the results without APC, averaged over 5 one-minute runs:</p>\n<pre><code>\nindex.html : 7067.57 req/sec\nindex.php  : 7484.57 req/sec # faster???\n</code></pre>\n<p>Here are the results with APC, averaged over 5 one-minute runs:</p>\n<pre><code>\nindex.html : 7013.50 req/sec\nindex.php  : 8041.06 req/sec # faster???\n</code></pre>\n<p>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?</p>\n<p><strong>UPDATE:</strong> With the help of <a href=\"http://blog.preinheimer.com/\">Paul Reinheimer</a>, we appear to have found the culprit: the <code>ab</code> tool itself seems to be at fault.  Running similar tests by hand with <code>siege</code> 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 <code>siege</code> later and report back.  Thanks to everyone who provided suggestions, and special thanks to Paul Reinheimer for working through it with me today.</p>\n"
}
