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 ...

Get Perl for Oracle DBAs now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.