Chapter 5. Embedding Perl into Apache with mod_perl

   

Although the Perl CGI methodology we discussed in Chapter 4, is an easy and popular approach to building web-based applications, there have historically been some performance problems with this approach. Whenever a Perl CGI script is run, the rather sizeable Perl interpreter must first be brought into memory before it can interpret and execute your program. Unfortunately, that can be a very slow process. Fans of Java servlets have pointed to this performance issue in advocating that their technology be used instead of Perl. But Perl has not taken this challenge from Java evangelists lying down! Apache's mod_perl module provides an interface between Apache and Perl that allows Perl code to be cached in the web server's memory space. The effect is a substantial improvement in performance over standard Perl CGI applications.

How much is substantial? As with so many things, the only real benchmarks are either for highly oversimplified cases (with no real application) or for highly specialized cases (with little extensibility). For most real-world programs, however, we can tell you that mod_perl provides a raw speed increase of approximately 40 to 60%. But this is only part of the story. The really significant gain is the vastly increased scalability provided through mod_perl because the interpreter is in memory and can be shared between processes.

The mod_perl module binds the Perl interpreter directly into the heart of the Apache server, thus avoiding the overhead of loading the interpreter into memory for each script executed on the server. As well as doing memory caching, this module also allows you to extend the Apache server in the Perl language itself. With mod_perl in place, the entire server-side Apache API becomes available to Perl programs. In this chapter, we'll describe mod_perl , as well as several related Apache modules:

mod_perl

The module that provides the interface between Apache and Perl.

Apache::Registry

An Apache module that is provided as a standard part of the mod_perl download. It greatly improves the performance of your CGI Perl scripts by evaluating your scripts into server subroutines that remain resident in the Apache server's memory.

Apache::DBI

This Apache module pools all of your database connections into memory. By providing persistent connections in this way, Apache::DBI greatly improves the performance of your Perl CGI scripts. This is a supplementary Apache module that you must obtain from CPAN.

Apache::OWA

To illustrate the effectiveness of mod_perl , we'll also show how it's used with the Apache::OWA Perl Apache module, which connects mod_perl to the PL/SQL Web Toolkit.

   


Perl for Oracle DBAs
Perl for Oracle Dbas
ISBN: 0596002106
EAN: 2147483647
Year: 2002
Pages: 137

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net