How could a CGI using ModPerl::Registry be faster than a Perl-Script
running under mod_perl? When I say 'faster', I'm talking a few tenths
of a second to half a second using Apache Benchmark (ab).
What really gets the water boiling is that the CGI is coded 'worse' (ie:
no strict, no warning, every var a global var, etc..). CGI even has a
require on tools.pl, so total CGI is 1347 lines. module is 952 lines.
CGI is not using DBI, nor ApacheDBI (its using some older mysql module).
CGI is even using 3 extra modules that MOD is not.
sniplets of my httpd.conf:
----------------------------------
StartServers 10
MinSpareServers 10
MaxSpareServers 15
MaxClients 150
MaxRequestsPerChild 500
PerlRequire /home/drmac/public_html/secconf/startup.pl
<Location /pages/sc2/roomlogin>
SetHandler perl-script
PerlResponseHandler testPkg::v2
# This matches
# http://www.mydomain.com/pages/sc2/roomlogin?roomID=3
</Location>
<Directory /home/drmac/public_html/pages/sc2/>
Options +ExecCGI
# This matches
# http://www.mydomain.com/pages/sc2/roomlogin.cgi?roomID=3
<FilesMatch "\.cgi$">
SetHandler perl-script
PerlResponseHandler ModPerl::PerlRun
PerlOptions +ParseHeaders
</FilesMatch>
</Directory>
--------------------------------------
Proof is in the puddin':
5 Trials each of "ab -c 2 -n 500"
<restarted apache>
Trial 1 CGI - 2.9265
Trial 2 CGI - 1.8933
Trial 3 CGI - 2.1517
Trial 4 CGI - 2.4451
Trial 5 CGI - 1.9838
<restarted apache>
Trial 1 MOD - 2.8199
Trial 2 MOD - 2.9183
Trial 3 MOD - 2.8225
Trial 4 MOD - 2.7791
Trial 5 MOD - 2.2639
At least the module is consistent in its performance. The CGI outputs
5378 bytes and the MOD outputs 5343, if that makes a difference.
Just ran "ab -c 5 -n 1000" once on each and CGI still beat MOD by 0.6
seconds.
Frustrated...
-Matthew