[cgiapp] Debugging Performance with CGI::Application Using Firebug and Time::HiRes
Rhesa Rozendaal
perl at rhesa.com
Thu Dec 30 17:05:49 EST 2010
On 12/30/2010 10:41 PM, Andy Daykin wrote:
> I am using mod_perl and here's what my httpd.conf file looks like:
>
> PerlModule ModPerl::Registry
> <Directory "/etc/apache2/cgi-bin">
> PerlResponseHandler ModPerl::Registry
> AllowOverride None
> Options None
> Order allow,deny
> Allow from all
> </Directory>
Cool (though /etc/apache2 is a very unconventional place for your
cgi-bin). I also recommend using a startup script to preload all your
modules. Add this to your httpd.conf:
PerlRequire /app_path/startup.pl
I think you can start out with this startup.pl:
#!/usr/bin/perl
use MyPage;
1;
> I used the time command to run my page from the command line and at first I
> was getting similar page load times to what I got before. When I put a die
> command like below I reduced the page load time only to ~5 seconds:
That sounds like it subtracts the page generation time, like you saw
earlier.
> #!/usr/bin/perl -w
>
> use strict;
>
> my $PRIVATE_HOME_DIR = '/app_path';
> use lib qw ( /app_path/modules );
> use CGI::Carp qw(fatalsToBrowser);
> die('done');
> use MyPage;
> MyPage->new(
> TMPL_PATH => $PRIVATE_HOME_DIR.'/templates'
> )->run;
>
>
> But when I kept the die statement and commented out the section where I load
> my module 'use MyPage', and new the module up, the page load times went down
> to less than a second. This tells me that simply loading my module is taking
> the bulk of the time but I can't figure out why. I am following the tutorial
> on https://docs.google.com/Doc?id=dd363fg9_77gb4hdh7b&pli=1 and the only
> thing I changed was the authentication. I am using LDAP instead of a
> database. Should loading all of the modules that I am using from the
> tutorial really take that much time? When I looked at the demo for the
> tutorial the page loads were very fast (within 2 seconds).
It's probably not the loading of the modules, since ModPerl::Registry
takes care of that (without a startup.pl, it'll only be slow on the
first hit. That's assuming you don't have something like
"MaxRequestsPerChild 1" in your httpd.conf). So the likely place will be
in either connecting to your LDAP server, or the I/O you're doing
against it. I'd suggest profiling with Devel::NYTProf (and its Apache
module), to see where it spends most of its time.
rhesa
More information about the cgiapp
mailing list