Today I took some benchmarks to see how PHP compares against mod_perl, and the results are quite interesting. (I probably wouldn't have posted them here, but some folks on the chatterbox demanded them.)
I have two scripts, that do the same thing: they connect to a MySQL address database and show a list of entries. They produce the same output. One is written in PHP, the other one is written in Perl, using CGI.pm and running as an Apache::Registry script under mod_perl.
The benchmarking tool I used is "ab", the Apache Benchmark that comes with the Apache distribution. I didn't tune the server at all, leaving default entries for configuration details like MinSpareServers (5), MaxSpareServers (10), StartServers (5), MaxClients (150), MaxRequestsPerChild (0).
I simulated 10 users, where each user will make 10 requests, so we have a total of 100 requests. Each script was tested several runs, and these are the average numbers of requests per second that Apache could handle:
Requests per second | |
Perl script under Apache::Registry (using CGI.pm) |
29 |
PHP script | 53! |
This was quite a shock to me. It means that the PHP script is almost twice as fast than the Perl script! Where has the famous performance of mod_perl gone?
I didn't want to believe this, so I hacked a third script, all in all a copy of the Perl script, only different in that I didn't use CGI.pm this time, but vanilla Apache methods for parameter handling, headers setup and so on. The results look like this:
Requests per second | |
Perl script under Apache::Registry (using CGI.pm) |
29 |
PHP script | 53 |
Apache::Registry script, without CGI.pm |
60! |
Wow, this is a big performance gain, isn't it? Almost the same script, but without CGI.pm. I'm curious if it can get faster when I make it a real content handler instead of an Apache::Registry script, but I didn't have the time for that.
Used hard- and software:
AMD K6 400MHz,
128 MB RAM
FreeBSD 4.1-STABLE
Apache 1.3.12
mod_perl 1.24
mod_php 4.0.2
DBI 1.14
Mysql-Modules 1.2214
|
---|
Replies are listed 'Best First'. | |
---|---|
Training wheels, part II (was: RE: Training wheels again)
by le (Friar) on Sep 04, 2000 at 23:40 UTC | |
RE: Training wheels again
by merlyn (Sage) on Sep 04, 2000 at 00:56 UTC | |
by le (Friar) on Sep 04, 2000 at 00:58 UTC | |
by arturo (Vicar) on Sep 08, 2000 at 20:02 UTC | |
by KM (Priest) on Sep 08, 2000 at 20:11 UTC | |
by le (Friar) on Sep 10, 2000 at 19:59 UTC | |
by merlyn (Sage) on Sep 10, 2000 at 20:06 UTC | |
| |
RE: Training wheels again
by strredwolf (Chaplain) on Sep 04, 2000 at 22:23 UTC | |
by elwarren (Priest) on Sep 08, 2000 at 01:51 UTC | |
by strredwolf (Chaplain) on Sep 08, 2000 at 08:12 UTC | |
RE: Training wheels again
by Anonymous Monk on Sep 06, 2000 at 05:00 UTC | |
RE: Training wheels again
by arturo (Vicar) on Sep 08, 2000 at 20:13 UTC | |
by KM (Priest) on Sep 08, 2000 at 20:28 UTC | |
RE: Training wheels again
by BastardOperator (Monk) on Sep 09, 2000 at 00:58 UTC | |
by le (Friar) on Sep 10, 2000 at 20:06 UTC |