 |
What is Mod Perl?
Mod_Perl is an Apache Module that makes Perl-based cgi scripts run many
times faster.
How much faster?
That depends on the script but 50 times as fast is possible.
How does it work?
When a cgi script is run:
1. Apache creates a new process and executes the script.
2.Perl compiles the code of the script.
3. The script runs and passes its output back to Apache.
4. Apache passes it along to the surfer.
This process is repeated for every request. Mod_Perl removes these steps
with two improvements. First, Mod_Perl has a Perl compiler built in so
that there is no need to create a new process (which saves a little time).
Second Mod_Perl keeps a copy of the compiled script and all its libraries
in memory so it never needs to recompile after the first time. The final
time-saver in the case of our scripts is that it also keeps the database
connections open between requests, saving even more time.
What are the advantages of Mod_Perl?
- Speed.
- Decreased memory use on busy sites since there is no need to compile
or fork for each request.
- On RedHat Linux (one of the most popular platforms) it's either already
installed or extremely easy to do so (with root access).
- Uses less memory than FastCGI. If script a.cgi and b.cgi both use library
c.pm, then only one copy of c.pm is stored in memory. With FastCGI, c.pm
would be in memory twice. Our scripts are designed to take advantage of
this.
What are the disadvantages of Mod_Perl?
- Increased memory usage on less-busy sites since compiled code is stored
in memory when it might not be needed again soon.
- Unless you are on RedHat Linux, it will probably require recompiling
Apache to install.
- Installation instructions are geared toward experienced Unix administrators
(not needed on RedHat).
|