Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

mod_perl vs CGI: benchmarks and code

by michellem (Friar)
on May 18, 2001 at 22:46 UTC ( [id://81580]=perlquestion: print w/replies, xml ) Need Help??

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

I'm thinking a lot about switching from cgi to mod_perl - I'm beginning to write a lot more complex web applications and I think that mod_perl is the way to go. But before I take the plunge - it seems like it's going to be a task to get everything together and do the conversions - I need to know a couple of things:

1) Are there benchmarks out there for mod_cgi vs. mod_perl speed/performance? What about when a large part of the work is db queries? In other words, I'm looking for concrete guidance on when (in terms of script complexity and loading times for dynamic pages) it makes sense to take the plunge.

2) I'm working on a fairly big db project - and it's something designed for release. I'd want it to be able to be used in either a cgi or mod_perl context - are there a lot of things I'll have to think about? Release two different versions? I have read the coding guidelines on perl.apache.org - so I'm not looking for details, but the general strategies people have used when releasing perl code for web applications.

Thanks in advance!

Replies are listed 'Best First'.
Re: mod_perl vs CGI: benchmarks and code
by arturo (Vicar) on May 18, 2001 at 22:53 UTC

    It's a no-brainer, if you're worried mainly about performance. Basic story: mod_perl embeds a perl interpreter in Apache. No starting up a separate perl interpreter when you start a CGI script! Secondly, Apache::DBI allows database connection pooling, and pretty intelligently. It's a *big* speed gain, but there is increased memory usage.

    If you code cleanly, and follow the guidelines you've already read, you shouldn't have much of a problem. Eventually, the thing to do is move away from thinking in terms of CGI scripts and writing mod_perl handlers; then, basically, you've got a big suite of Perl apps that groks HTTP ... mondo powerful. Why, you could even write a great website around that sort of technology!

    perl -e 'print "How sweet does a rose smell? "; chomp ($n = <STDIN>); +$rose = "smells sweet to degree $n"; *other_name = *rose; print "$oth +er_name\n"'
      Contrary to the w3c advise you shouldnt use em for font sizes, and you should rather use px. Reason 1: If you use em then as screens become more advanced with better resultion and bigger sizes then you font gets smaller as in the examples on this page. Reason 2: People with eye proplems set their screen res smaller because they want the text to get bigger - thats the whole point of screen res. Eugene
        Both em and px will shrink as the resolution increases. The difference is that em is based on the user's preferred font size and is thus a better choice from the user's point of view.

        This is exactly backwards. Increasing screen resolution makes pixels smaller on the screen. All modern operating systems and browsers have type display controls independent of screen resolution and that's how those with special requirements should handle it.

Re: mod_perl vs CGI: benchmarks and code
by Masem (Monsignor) on May 19, 2001 at 01:48 UTC
    As per your question on a co-developing non-mod_perl vs mod_perl:

    If you develop all your code under a mod_perl environment, it should be a no-brainer to simply transfer the code to a non-mod_perl site; it should work without changes.

    The reverse is not true; non-mod_perl code can easily fail under a mod_perl environment if the developement did not plan ahead for it.

    Mind you, this assumes you don't use some of the more specialized features of mod_perl; if you do start using those, there is an immediate divergence of what you can do in mod_perl and what you can do in non-mod_perl, and maintaining both at this point would be hopeless (or rather difficult).


    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
Re: mod_perl vs CGI: benchmarks and code
by fpina (Pilgrim) on May 19, 2001 at 03:00 UTC

    We've done a benchmark of mod_perl / FastCGI against regular CGIs, and the results where roughly that the same script runs around twice as fast under mod_perl or FastCGI than as a CGI. These results were got without changing the CGI at all, i.e. they might even get better if you tweak the script to take advantage of special characteristics of mod_perl and FastCGI. These two seem to offer similar performances.

Re: mod_perl vs CGI: benchmarks and code
by scottstef (Curate) on May 19, 2001 at 02:53 UTC
    Something else that I think that should be discussed is fast cgi. Apparently it is faster. I have not done any benchmarking on it, but I have used it on a web calendar application that ties into an ldap directory for authentication/account creation and a reima(i think that is the correct spelling) database for the the calendar data. Would that be a "faster" way to integrate what needs to be done?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://81580]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-24 21:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found