Recently, I've been doing a lot of benchmarking with Apache to compare different OSes and platforms. I did a stock install of Ubuntu 7.04 Server w/ Apache2 and PHP5. To do the test, I used ab to fetch the following document: <html>
<head>
<title>PHP Web Server Test</title>
</head>
<body>
<?php phpinfo(); ?>
</body>
</html> I ran ab in a loop 12 times with 10,000 connections and a concurrency of 10. Then I threw out the highest result and the lowest result and averaged the remaining values. The results were somewhat surprising to me: on average, PHP4 significantly outperformed PHP5. Over our LAN PHP5 handled roughly 1,200 requests / sec while PHP4 handled over 1,800 requests / sec. Since everything I have heard/read is that PHP5 is much faster than PHP4, I expected the opposite to be true, but the numbers are what they are. The only difference I can figure is that PHP5 was the packaged version that comes with Ubuntu and I had to compile PHP4 from source since there is no package for it in Feisty. But I wouldn't expect a 50% increase as a result of that. Any thoughts on this?Are you running both PHP versions as Apache modules, or is one a module and the other CGI? (If PHP 5 was being run as CGI while PHP 4 as an Apache module -- which is often done to allow both versions to co-exist on one server -- then I would expect the CGI version to be slower, as it has to kick off a new PHP process on each request.)Are you running both PHP versions as Apache modules, or is one a module and the other CGI? (If PHP 5 was being run as CGI while PHP 4 as an Apache module -- which is often done to allow both versions to co-exist on one server -- then I would expect the CGI version to be slower, as it has to kick off a new PHP process on each request.) No, both were running as apache modules. This is a demo box, so I had the ability to swap out modules in the config files without any problems.Let me get this right - you're trying to measure the performance of web hits on phpinfo() on Apache?
Is this at all useful? Will you ever be doing this in a production environment?
phpinfo() outputs different stuff on different versions of PHP. This means your test is essentially meaningless.
If you want to actually benchmark real code:
1. Throw Apache out of the loop- measure performance of PHP using the CLI
2. Use a program which runs for at least a few seconds, and loops calling the functions you want to test many times.
3. If you're comparing PHP4 and PHP5, make sure they're running the same code and it gets the same results!
I can't stress how pointless it is measuring the speed of phpinfo().
Mark
<head>
<title>PHP Web Server Test</title>
</head>
<body>
<?php phpinfo(); ?>
</body>
</html> I ran ab in a loop 12 times with 10,000 connections and a concurrency of 10. Then I threw out the highest result and the lowest result and averaged the remaining values. The results were somewhat surprising to me: on average, PHP4 significantly outperformed PHP5. Over our LAN PHP5 handled roughly 1,200 requests / sec while PHP4 handled over 1,800 requests / sec. Since everything I have heard/read is that PHP5 is much faster than PHP4, I expected the opposite to be true, but the numbers are what they are. The only difference I can figure is that PHP5 was the packaged version that comes with Ubuntu and I had to compile PHP4 from source since there is no package for it in Feisty. But I wouldn't expect a 50% increase as a result of that. Any thoughts on this?Are you running both PHP versions as Apache modules, or is one a module and the other CGI? (If PHP 5 was being run as CGI while PHP 4 as an Apache module -- which is often done to allow both versions to co-exist on one server -- then I would expect the CGI version to be slower, as it has to kick off a new PHP process on each request.)Are you running both PHP versions as Apache modules, or is one a module and the other CGI? (If PHP 5 was being run as CGI while PHP 4 as an Apache module -- which is often done to allow both versions to co-exist on one server -- then I would expect the CGI version to be slower, as it has to kick off a new PHP process on each request.) No, both were running as apache modules. This is a demo box, so I had the ability to swap out modules in the config files without any problems.Let me get this right - you're trying to measure the performance of web hits on phpinfo() on Apache?
Is this at all useful? Will you ever be doing this in a production environment?
phpinfo() outputs different stuff on different versions of PHP. This means your test is essentially meaningless.
If you want to actually benchmark real code:
1. Throw Apache out of the loop- measure performance of PHP using the CLI
2. Use a program which runs for at least a few seconds, and loops calling the functions you want to test many times.
3. If you're comparing PHP4 and PHP5, make sure they're running the same code and it gets the same results!
I can't stress how pointless it is measuring the speed of phpinfo().
Mark