11. Web Server Programming with mod_perl
Contents:
A common criticism of CGI is that it requires forking extra processes each time a script is executed. If you only have a few hits an hour, or even a few hits a minute, this isn't a big deal. But for a high-traffic site, lots of CGI scripts repeatedly spawning can have an unfortunate effect on the machine running the web server. The CGI scripts will be slow, the web server will be slow, and other processes on the machine will come to a crawl. The solution to this problem is mod_perl . mod_perl , written by Doug MacEachern and distributed under CPAN, embeds the Perl interpreter directly into the web server. The effect is that your CGI scripts are precompiled by the server and executed without forking, thus running much more quickly and efficiently. Furthermore, CGI efficiency is only one facet of mod_perl . Since mod_perl is a complete Apache/Perl hybrid, other benefits to mod_perl include:
11.1 Design of mod_perlmod_perl is not a Perl module. It is a module of the Apache server, which is currently the most commonly used web server. With mod_perl , you can use Apache configuration directives not only to process CGI scripts much more efficiently, but also to handle all stages in processing a server request.
mod_perl
embeds a copy of the Perl interpreter into the
Apache
httpd
executable, providing complete access to
Perl functionality within Apache.
This enables a set of
mod_perl
-specific configuration directives,
all of which start with the string It might occur to you that sticking a large program into another large program makes a very, very large program. mod_perl certainly makes httpd significantly bigger. If you have limited memory capacity, mod_perl may not be for you. There are several ways to minimize the size of Apache with mod_perl (which you can find in the mod_perl manpage or the FAQs), ranging from fiddling with Apache configuration directives to building Perl with reduced memory consumption. |
|