spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / perl / mysqlperl / chap3 / 1 current pagecurrent pageTo page 3
[next]
Developer News
Mandrake Linux Founder Back, Virtually
Amazon: We're a Technology Company
Sun Expands MySQL With Closed Source

Improving Performance with mod_perl

What mod_perl Is and How It Works

When Apache receives a request for a static HTML file, it can serve the request directly by opening the file and writing it out over the network to the client. This is not true for programs, such as the Perl cgi-bin scripts we wrote in Chapter 2. Those scripts aren't processed by Apache itself. Instead, Apache starts up Perl as an external process and returns its output to the requesting client. This works well for extending Apache's capabilities, but invoking an external program taxes the Web server host and also introduces some delay into serving the request. This overhead is incurred repeatedly as script requests arrive because Apache starts up a new Perl process to handle each one.

An alternative to running scripts using external processes is to make the script handler part of Apache itself. In the case of Perl scripts, we can use the mod_perl module to embed the Perl interpreter into Apache. The result is that Apache gains the capability to execute Perl scripts directly. This approach has several advantages:

  • Apache can execute Perl scripts more quickly because it need not start up or wait for standalone external processes.

  • A given Apache process can serve many script requests because it doesn't terminate when a script finishes; it just waits for the next request. This allows Apache to perform caching for scripts that are requested repeatedly, which results in a further performance improvement. (The script-execution process involves examining the script and compiling it to an internal form, and then running that form. When Perl runs as part of Apache, the compiled script remains loaded in memory and is immediately available for execution. It need not be recompiled if the server receives another request for it.)

  • Because the Perl interpreter doesn't just exit when the script terminates the way it does when Perl is executed as a standalone process, the script-execution environment persists across scripts. This makes possible some things that can't be done when scripts are executed individually by independent Perl processes. One of these is persistent database connections (connections to a database server that can be shared over successive scripts, minimizing overhead for setup and teardown).

home / programming / perl / mysqlperl / chap3 / 1 current pagecurrent pageTo page 3
[next]

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Working with the DOM Stylesheets Collection · Administering RBAC in PHP 5 CMS Framework · xref: Automatic Cross Referencing Script
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Combine BottomCount() with Other MDX Functions to Add Sophistication · Creating a Daemon with Python · The Coming Voice-over-WiMAX Revolution


Created: June 26, 2001
Revised: June 26, 2001


URL: http://webreference.com/programming/perl/mysqlperl/chap3/1/