[cgiapp] Debugging Performance with CGI::Application Using Firebug and Time::HiRes

Andy Daykin daykinandy at gmail.com
Thu Dec 30 16:41:32 EST 2010


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>

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:

#!/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).



On Thu, Dec 30, 2010 at 1:21 PM, Rhesa Rozendaal <perl at rhesa.com> wrote:

> On 12/30/2010 03:49 PM, Andy Daykin wrote:
> > I have been trying to find where the performance issues in my code are
> > coming from, but there is time that is unaccounted for when I have been
> > trying to debug a sites performance written with CGI::Application.
>
> These are the main steps that take time:
>
> 1. establish connection with web server
> 2. send request
> 3. web server runs your app
> 4. your app generates the response
> 5. receive response
>
> Your code below only measures step 4, so if you find that that does not
> account for the bulk of the time, then it must be in one of the other
> steps.
>
> As a start, I would run
>
>   time page.cgi
>
> This will show you the combined time of steps 3 and 4 (I'm assuming
> you're not using mod_perl or fcgi or some other persistence framework).
> This will include the time it takes to load all of the modules your
> MyPage module uses, and all the modules they depend on in turn. If you
> have a lot of dependencies, or expensive things to set up (database
> connections, connections to other types of servers, etc), this may be
> the most time-consuming part.
>
> If that doesn't account for the bulk of the time, then it looks like the
> network i/o is the bottleneck. I believe firebug tells you the times for
> connect, send, and receive, so you should already have seen this (and
> since you say you're on a LAN, this is unlikely to be the bottleneck).
>
> If the bottleneck is in fact in the execution of your cgi script, then
> I'd profile it with Devel::NYTProf to find out what the hot spots are.
> The next thing I'd grab for would be mod_perl. The third step would be
> making sure that as much of the expensive setup is done only once per
> mod_perl process.
>
> HTH,
> Rhesa
>
> #####  CGI::Application community mailing list  ################
> ##                                                            ##
> ##  To unsubscribe, or change your message delivery options,  ##
> ##  visit:  http://lists.openlib.org/mailman/listinfo/cgiapp    ##
> ##                                                            ##
> ##  Web archive:   http://lists.openlib.org/pipermail/cgiapp/   ##
> ##  Wiki:          http://cgiapp.erlbaum.net/                 ##
> ##                                                            ##
> ################################################################
>
>


-- 
http://www.andydaykin.com


More information about the cgiapp mailing list