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

Ok, the other day I discovered mod_perl and how cool it can be with its more efficient speed and so on when being used to program scripts with. (Yes, i'm still a newbie, thus why I 'just' discovered this perl jewel. :)) I have a question that you people might be able to help me out with. Is there any way to benchmark code written with mod_perl? Or does anyone have benchmarks on average code using mod_perl? Thanks if anyone can be of help! Any and all help will be appreciated and used well.

bladx ~ ¡muchas veces tengo preguntas!

Replies are listed 'Best First'.
Re: Benchmarks of mod_perl
by arturo (Vicar) on Mar 02, 2001 at 21:06 UTC

    The big speed boost you get with mod_perl over traditional CGI isn't really in the execution speed of the code. It's in the fact that the webserver doesn't have to start a new Perl interpreter and compile the script for each CGI request. So "mod_perl code" doesn't, in one good sense, run any faster than the code outside mod_perl. For fine-tuning your code, you probably want to use a combination of Benchmark and something like Devel::DProf. (note: that will only help you test out the efficiency of various algorithms; but since the integration of Perl and Apache that is mod_perl is a different environment from that of traditional CGI , it's not so obvious that you'll be able to port conclusions about how fast this script is as traditional CGI to how fast it will be under mod_perl directly; mod_perl is much more powerful than traditional CGI, which is a reason to use it independent of any speed gain)

    Given that mod_perl is helping you serve web pages, the best way to measure it is to simulate an actual setup and see how it deals with it. Write a script that uses LWP to make requests to the server, and see how many pages it can serve up in a given interval. That's probably the only way to test the relative speed of mod_perl vs. say, PHP or JSP or ... $dynamic_web_content_technology

    HTH

    Philosophy can be made out of anything. Or less -- Jerry A. Fodor

      Writing a CGI program with mod_perl is more complex than writing a CGI program with perl. It was a very daunting task for me to have to 'port' my code over to mod_perl.What I did instead was use a module called Apache::PerlRun, you won't get the same performance increase as if you written your CGI with mod_perl, but if helps.

      What I think it does is compiles your perl code and keeps it resident in memory.

      here's the entry in my httpd.conf:

      <Location /cgi-bin> SetHandler perl-script PerlHandler Apache::PerlRun PerlSendHeader On Options +ExecCGI </Location>
Re: Benchmarks of mod_perl
by Anonymous Monk on Mar 02, 2001 at 21:30 UTC
    Apache comes with a benchmark program called ab, you can use it to benchmark mod_perl vs. CGI.
Re: Benchmarks of mod_perl
by chromatic (Archbishop) on Mar 02, 2001 at 22:26 UTC
    Benchmarks are hard to do normally, especially when dealing with web requests. Not only does program speed matter, but memory, memory usage, disk I/O, and network throughput.

    That said, the mod_perl guide has a good chapter on Performance Tuning that's given me a few tricks.