perl_lover has asked for the wisdom of the Perl Monks concerning the following question:

I am working with a mod_perl application which uses a huge database.
when i am logging the time taken by each page in error log through CGI.pm and Apache Profiler, i am getting a response time of 30 Secs.
But when i use Apache Benchmark tool (ab) its giving the time taken as 300 mili Sec. Will ab give only server response time ??? How can i get the complete time taken by the page to load ????

-perl_lover

Replies are listed 'Best First'.
Re: BenchMarking mod_perl application
by holli (Abbot) on Feb 25, 2005 at 13:04 UTC
    simply use LWP::Simple and Benchmark:
    use strict; use warnings; use Benchmark; use LWP::Simple; my $t = timeit(1, sub { get "http://www.perlmonks.org"; }); print timestr($t),"\n";


    holli, /regexed monk/
Re: BenchMarking mod_perl application
by CountZero (Bishop) on Feb 25, 2005 at 13:47 UTC
    Unless you can control the whole of the network the data has to pass through, the results of your benchmarking will be severely conditioned by the status of the network.

    In my experience such benchmarking is next to useless.

    What I have done is adding some print statements showing the start-time and end-time of the running of the script and of the start and end-times of the database queries, so you can see where the delay is.

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

      Why not just run the benchmark off localhost?

      "There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

        That is of course possible but using one computer both for the web-server, database-server and browser (and the Gods know what other processes running in the background) will of course also skew the results.

        It is a bit like quantummechanics: the act of measuring already distorts the reality.

        CountZero

        "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Re: BenchMarking mod_perl application
by mpeters (Chaplain) on Feb 25, 2005 at 16:21 UTC
    Like others have said before me it really depends on what you want to measure. If you have control of the network (meaning you are directly connected to the sever) then holli's advice would probably be the best since it would take into account the server overhead time which should be much better under mod_perl.

    If you don't have control over the network, I would say running something like holli's script on the same box would be better than trying it over a messy network. And Javascript would not be able to give you an accurate benchmark of anything other than how long the page takes to render which is not what you are asking (I believe).
Re: BenchMarking mod_perl application
by perrin (Chancellor) on Feb 25, 2005 at 18:07 UTC
    That difference is too big to be explained by browser rendering. I suspect you are misreading the ab output. How about showing us the command you used to run it and the output? Also, you must know whether the page takes 30 seconds or a fraction of a second. Which is it?
Re: BenchMarking mod_perl application
by hardburn (Abbot) on Feb 25, 2005 at 20:27 UTC

    Apache goes through several phases to handle a request. After the data is sent to the client, there are some cleanup phases. That could potentially take a while, depending on your configuration.

    "There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

Re: BenchMarking mod_perl application
by RazorbladeBidet (Friar) on Feb 25, 2005 at 13:09 UTC
    Wouldn't it be best to use JavaScript for that, since it's client-dependent? I should be able to find some if that's what you're looking for.

    Back in my mod_perl days (5 years ago) I used Apache::DProf but that was for the Perl side only.

    I'd be wary of any "total time" you get because it's going to involve a lot of factors and may lead you down the wrong path.
    --------------
    It's sad that a family can be torn apart by such a such a simple thing as a pack of wild dogs