Apache-ASP
view release on metacpan or search on metacpan
site/tuning.html view on Meta::CPAN
<td valign=top >
<font face="lucida console" size=-1>
<a href=#Precompile%20Sfb36ef6e>Precompile Scripts</a>
</font>
</td>
</tr>
<tr>
<td valign=top >
<font face="lucida console" size=-1>
<a href=#Tuning%20%26%20Ben0cdacf8c>Tuning & Benchmarking</a>
</font>
</td>
<td valign=top >
<font face="lucida console" size=-1>
<a href=#No%20.htaccessc4c9e884>No .htaccess or StatINC</a>
</font>
</td>
</tr>
<tr>
<td valign=top >
<font face="lucida console" size=-1>
<a href=#%24Application941f90bf>$Application & $Session State</a>
</font>
</td>
<td valign=top >
<font face="lucida console" size=-1>
<a href=#Turn%20off%20Debe0bab100>Turn off Debugging</a>
</font>
</td>
</tr>
<tr>
<td valign=top >
<font face="lucida console" size=-1>
<a href=#Low%20MaxClien5a8237ea>Low MaxClients</a>
</font>
</td>
<td valign=top >
<font face="lucida console" size=-1>
<a href=#Memory%20Sparia73a9626>Memory Sparing, NoCache</a>
</font>
</td>
</tr>
<tr>
<td valign=top >
<font face="lucida console" size=-1>
<a href=#High%20MaxRequ0724a06d>High MaxRequestsPerChild</a>
</font>
</td>
<td valign=top >
<font face="lucida console" size=-1>
<a href=#Resource%20Limfd66f2d8>Resource Limits</a>
</font>
</td>
</tr>
<tr>
<td valign=top >
<font face="lucida console" size=-1>
<a href=#Precompile%20M39676a96>Precompile Modules</a>
</font>
</td>
<td> </td>
</tr>
</table>
<hr size=1>
<p>
<p>
<a name=Online%20Resou44921f06></a>
<font face=verdana><font class=title size=+0 color=#555555><b>Online Resources</b></font>
<font face="courier new" size=3><pre>
</pre></font>For more tips & tricks on tuning Apache and <a href=http://perl.apache.org><font size=-1 face=verdana><b>mod_perl</b></font></a>, please see the tuning
documents at:
<font face="courier new" size=3><pre>
<a href="http://perl.apache.org/guide/">Stas Bekman's mod_perl guide</a>
</pre></font>Written in late 1999 this article provides an early look at
how to tune your Apache::ASP web site. It has since been
updated to remain current with Apache::ASP v2.29+
<font face="courier new" size=3><pre>
<a href="http://www.apache-asp.org/articles/perlmonth3_tune.html">Apache::ASP Site Tuning</a>
</pre></font>
<p>
<a name=Tuning%20%26%20Ben0cdacf8c></a>
<font face=verdana><font class=title size=+0 color=#555555><b>Tuning & Benchmarking</b></font>
<font face="courier new" size=3><pre>
</pre></font>When performance tuning, it is important to have a tool to
measure the impact of your tuning change by change.
The program ab, or Apache Bench, provides this functionality
well, and is freely included in the apache distribution.
<font face="courier new" size=3><pre>
</pre></font>Because performance tuning can be a neverending affair,
it is a good idea to establish a threshold where performance
is "good enough", that once reached, tuning stops.</font>
<p>
<a name=%24Application941f90bf></a>
<font face=verdana><font class=title size=+0 color=#555555><b>$Application & $Session State</b></font>
<font face="courier new" size=3><pre>
</pre></font>Use NoState 1 setting if you don't need the $Application or $Session
objects. State objects such as these tie to files on disk and will incur a
performance penalty.
<font face="courier new" size=3><pre>
</pre></font>If you need the state objects $Application and $Session, and if
running an OS that caches files in memory, set your "StateDir"
directory to a cached file system. On WinNT, all files
may be cached, and you have no control of this. On Solaris, /tmp is
a RAM disk and would be a good place to set the "StateDir" config
setting to. When cached file systems are used there is little
performance penalty for using state files. Linux tends to do a good job
caching its file systems, so pick a StateDir for ease of system
administration.
<font face="courier new" size=3><pre>
</pre></font>On Win32 systems, where <a href=http://perl.apache.org><font size=-1 face=verdana><b>mod_perl</b></font></a> requests are serialized, you
can freely use SessionSerialize to make your $Session requests
faster, and you can achieve similar performance benefits for
$Application if you call $Application->Lock() in your
global.asa's Script_OnStart.</font>
<p>
<a name=Low%20MaxClien5a8237ea></a>
<font face=verdana><font class=title size=+0 color=#555555><b>Low MaxClients</b></font>
<font face="courier new" size=3><pre>
</pre></font>Set your MaxClients low, such that if you have that
many httpd servers running, which will happen on busy site,
your system will not start swapping to disk because of
excessive RAM usage. Typical settings are less than 100
even with 1 gig RAM! To handle more client connections,
look into a dual server, mod_proxy front end.</font>
<p>
<a name=High%20MaxRequ0724a06d></a>
<font face=verdana><font class=title size=+0 color=#555555><b>High MaxRequestsPerChild</b></font>
<font face="courier new" size=3><pre>
</pre></font>Set your max requests per child thread or process (in httpd.conf) high,
so that ASP scripts have a better chance being cached, which happens after
they are first compiled. You will also avoid the process fork penalty on
UNIX systems. Somewhere between 50 - 500 is probably pretty good.
You do not want to set this too high though or you will risk having
your web processes use too much RAM. One may use Apache::SizeLimit
or Apache::GTopLimit to optimally tune MaxRequestsPerChild at runtime.</font>
<p>
<a name=Precompile%20M39676a96></a>
<font face=verdana><font class=title size=+0 color=#555555><b>Precompile Modules</b></font>
<font face="courier new" size=3><pre>
</pre></font>For those modules that your Apache::ASP application uses,
make sure that they are loaded in your sites startup.pl
file, or loaded with PerlModule in your httpd.conf, so
that your modules are compiled pre-fork in the parent httpd.</font>
<p>
<a name=Precompile%20Sfb36ef6e></a>
<font face=verdana><font class=title size=+0 color=#555555><b>Precompile Scripts</b></font>
<font face="courier new" size=3><pre>
</pre></font>Precompile your scripts by using the Apache::ASP->Loader() routine
documented below. This will at least save the first user hitting
a script from suffering compile time lag. On UNIX, precompiling scripts
upon server startup allows this code to be shared with forked child
www servers, so you reduce overall memory usage, and use less CPU
compiling scripts for each separate www server process. These
savings could be significant. On a PII300 Solaris x86, it takes a couple seconds
to compile 28 scripts upon server startup, with an average of 50K RAM
per compiled script, and this savings is passed on to the ALL child httpd
servers, so total savings would be 50Kx28x20(MaxClients)=28M!
<font face="courier new" size=3><pre>
</pre></font>Apache::ASP->Loader() can be called to precompile scripts and
even entire ASP applications at server startup. Note
also that in modperl, you can precompile modules with the
PerlModule config directive, which is highly recommended.
<font face="courier new" size=3><pre>
Apache::ASP->Loader($path, $pattern, %config)
</pre></font>This routine takes a file or directory as its first argument. If
a file, that file will be compiled. If a directory, that directory
will be recursed, and all files in it whose file name matches $pattern
will be compiled. $pattern defaults to .*, which says that all scripts
in a directory will be compiled by default.
<font face="courier new" size=3><pre>
</pre></font>The %config args, are the config options that you may want set that affect
compilation. These options include: Debug, Global, GlobalPackage,
DynamicIncludes, IncludesDir, InodeNames, PodComments, StatINC, StatINCMatch, UseStrict,
XMLSubsPerlArgs, XMLSubsMatch, and XMLSubsStrict. If your scripts are later run
with different config options, your scripts may have to be recompiled.
<font face="courier new" size=3><pre>
</pre></font>Here is an example of use in a *.conf file:
<font face="courier new" size=3><pre>
<Perl>
Apache::ASP->Loader(
'/usr/local/proj/site', "(asp|htm)\$",
'Global' => '/proj/perllib',
'Debug' => -3, # see system output when starting apache
( run in 2.056 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )