Re: How to test if I got Mod_Perl in apache?

From: Douglas Hunter (dug_at_plusthree.com)
Date: 10/03/04


Date: 3 Oct 2004 14:21:14 GMT

On 2004-10-03, Sherm Pendley <spamtrap@dot-app.org> wrote:
> Gunnar Hjalmarsson wrote:
>
>> Quote from http://perl.apache.org/start/tips/registry.html :
>>
>> "Existing CGI scripts will run much faster under mod_perl."
>
> That has not been my experience - and I've done a *lot* of mod_perl, for
> sites that get more traffic than slashdot.
>

I'd be interested in hearing more about your typical configuration. Do
you use fastcgi or Pperl? I believe that statement assumes a typical CGI
environment rather than a persistent one.

> On the other hand, the scripts I've worked with have been as small and
> tight as I could make them to begin with. They didn't benefit all that
> much by simply dropping them into Apache::Registry, since the compiler
> overhead for those scripts wasn't all that much to begin with.

I just benched the smallest and tightest script I could come up with:

#!/usr/bin/perl

print "Content-Type: text/html\r\n\r\n";
print "<html>Hello World!</html>";

{grin}

A vanilla CGI run of 3000 (using ab -n 3000) gave me 175.36 requests per
second. Moving that over to mod_perl and Apache::Registry gave me
298.15. I'd call that a significant difference. Of course, those
numbers will favor mod_perl even more as the complexity of the script
grows, especially if folks follow best practices and pre-load heavy
modules before apache forks.

Running 20 concurrent processes (ab -n 3000 -c 20) shows even more favor
for mod_perl: 371.24 for mod_perl to 187.85 for CGI.

>
> I can see where the difference would be much more dramatic though, if
> you're dealing with a 10kloc behemoth that spends as much or more time
> compiling than it does running. ;-)

Unless one is running in a persistent environment such as fastcgi or
Pperl, the basic fork and exec that is needed to execute a cgi script
causes a significant amount of overhead, meaning a win for simply
switching to mod_perl. Of course, you are correct in saying that as
things grow more complex that the difference becomes more dramatic
{grin}.

>
> sherm--
>

  -- Douglas Hunter



Relevant Pages

  • Re: what www perl script is running?
    ... $ sudo lsof | grep perl ... The script is talking to 94.102.51.57 on port 7000. ... I have disabled both CGI and fastCGI in lighttpd.conf, ...
    (freebsd-questions)
  • Re: Key-passing from PHP to TCL CGI script - how is it done (web security issue)?
    ... TCL v.8.3 ... set hasEnteredTrivia 0 ... # NEW 8/7/2004 USE PHP (AS CGI) TO CHECK IF USER IS ATTEMPTING TO ENTER ... # USE REMOTE PHP SCRIPT TO CHECK FOR REPOSTING ...
    (comp.lang.tcl)
  • Re: Changing Passwords through the web (fwd)
    ... I use a CGI script that uses the poppassd and python ports on my small ... alert; ...
    (FreeBSD-Security)
  • Re: Help with a stragegy for diagnosis
    ... I have a Perl CGI that has work for years. ... first failure and before the second. ... A strategy would be to write tests for the script until you get the same ...
    (comp.lang.perl.moderated)
  • Re: Recommend PHP-Based Dashboard?
    ... and this is to illicite a response from php developers in a php usenet group trying to foster some kind of fear in us all that you may change your mind and go java or windows or mac? ... as i run true cgi scripts from the cgi exe *all the time* from the command-line, i assure you that you're wrong. ... the above explicitly states that i must use a feature of cgi in order to be considered a cgi script. ...
    (comp.lang.php)