Optimizing mod_perl
If you use Apache, you can preload some modules and speed up processing.
Preloading Perl Modules at Server Startup
You can use the PerlRequire and PerlModule directives to load
commonly used modules such as CGI.pm, DBI and etc., when the server
is started. On most systems, server children will be able to share
the code space used by these modules. Just add the following directives
into httpd.conf:
PerlModule CGI
PerlModule DBI
But an even better approach is to create a separate startup file
(where you code in plain perl) and put there things like:
use DBI ();
use Carp ();
Don't forget to prevent importing of the symbols exported by default
by the module you are going to preload, by placing empty parentheses
() after a module's name. Unless you need some of these in the startup
file, which is unlikely. This will save you a few more memory bits.
Then you require() this startup file in httpd.conf with the PerlRequire
directive, placing it before the rest of the mod_perl configuration
directives:
PerlRequire /path/to/start-up.pl
Please follow
this link to read the full original article by Stas Beckman.
|