Phoenix.pm: mod_perl

Andrew Johnson lajandy at yahoo.com
Wed Mar 27 14:26:15 CST 2002


--- Lowell Hamilton <syz at broken-bit.com> wrote:
> I have a big stack of web applications that are just straight
> CGI.pm/DBI
> built a year or so ago .. now with site traffic peaking they're
> running
> slow as mud.
> 
> Anyone have a good resource for modifying existing apps to run
> smoothly
> under mod_perl?  (unfortunately there isn't a book with a camel and
> an
> indian riding it).

Actually, the book has an eagle on it.  _Writing Apache Modules in Perl
and C_ by Lincoln Stein and Doug MacEachern (aka the mod_perl book, aka
the Eagle book).  There's now also a mod_perl Cookbook
(http://www.modperlcookbook.org), though it's not published by O'Reilly

> Google has failed me on this one and I've done
> almost no mod_perl development except for Apache::DBI before so I
> don't
> know really where to start.

http://perl.apache.org

is the official site, though you'd probably specifically want the Quick
Guide for moving from CGI to mod_perl:

http://perl.apache.org/dist/cgi_to_mod_perl.html

There links to many other resources at perl.apache.org.

<rant>
I would also like to issue a STERN WARNING:

Mod_perl is not CGI.  Mod_perl provides access to the entire Apache API
via Perl, and enables one to write web applications that run _inside
the server itself_, not in a relatively protected separate process like
CGI scripts.  If you write bad code, you will crash the daemon it's
running in, and you may crash the whole server.  If you write sloppy
code, you will have memory leaks.  And although Apache::Registry will
run your properly prepared CGI scripts, you will still be running those
scripts inside the server, and if your code is bad, you will have a web
server that runs badly.  I know this sounds somewhat condescending, but
I can't tell you how many times I've been told (by people that should
know better) that mod_perl is unstable, and it runs so slowly, and it
can't do xyz.  And then I'll ask them about their setup, and find out
they didn't bother to clean up the CGIs, or didn't bother to do any
tuning, or used globals that "leaked" into packages where they
shouldn't be, and 10,000 different other things.  This always boiled
down to "I just wanted it run my dirty old CGI scripts, and didn't
bother to consider the consequences."  You simply cannot do that with
mod_perl and have good performance.

Read the books, read the docs linked to on the perl.apache.org site,
and use proper coding techniques, though, and you'll be golden.
</rant>

We now return you to your regularly scheduled lives.



=====


__________________________________________________
Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards®
http://movies.yahoo.com/



More information about the Phoenix-pm mailing list