summaryrefslogtreecommitdiff
path: root/docs/manual/misc/perf-scaling.html.en
diff options
context:
space:
mode:
Diffstat (limited to 'docs/manual/misc/perf-scaling.html.en')
-rw-r--r--docs/manual/misc/perf-scaling.html.en388
1 files changed, 194 insertions, 194 deletions
diff --git a/docs/manual/misc/perf-scaling.html.en b/docs/manual/misc/perf-scaling.html.en
index d36860e04b..b855f8ce74 100644
--- a/docs/manual/misc/perf-scaling.html.en
+++ b/docs/manual/misc/perf-scaling.html.en
@@ -24,8 +24,8 @@
<p><span>Available Languages: </span><a href="../en/misc/perf-scaling.html" title="English">&nbsp;en&nbsp;</a></p>
</div>
-
- <p>The Performance Tuning page in the Apache 1.3 documentation says:
+
+ <p>The Performance Tuning page in the Apache 1.3 documentation says:
</p>
<blockquote><p>
"Apache is a general webserver, which is designed to be
@@ -43,14 +43,14 @@
The classic brochureware site is alive and well, but the web has
grown up substantially as a computing application platform and
webmasters may find themselves running dynamic content in Perl, PHP
- or Java, all of which take a toll on performance.
+ or Java, all of which take a toll on performance.
</p>
<p>Therefore, in spite of strides forward in machine speed and
bandwidth allowances, web server performance and web application
performance remain areas of concern. In this documentation several
- aspects of web server performance will be discussed.
+ aspects of web server performance will be discussed.
</p>
-
+
</div>
<div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#what-will-and-will-not-be-discussed">What Will and Will Not Be Discussed
</a></li>
@@ -76,9 +76,9 @@
server hardware, so the existing infrastructure will have to do the
job. You have no desire to compile your own Apache, or to recompile
the operating system kernel. We do assume, though, that you have
- some familiarity with the Apache httpd configuration file.
+ some familiarity with the Apache httpd configuration file.
</p>
-
+
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="monitoring-your-server" id="monitoring-your-server">Monitoring Your Server
@@ -88,15 +88,15 @@
find out how your system is currently performing. By monitoring
your server under real-world load, or artificially generated load,
you can extrapolate its behavior under stress, such as when your
- site is mentioned on Slashdot.
+ site is mentioned on Slashdot.
</p>
-
-
+
+
<h3><a name="monitoring-tools" id="monitoring-tools">Monitoring Tools
</a></h3>
-
-
+
+
<h4><a name="top" id="top">top
</a></h4>
@@ -113,9 +113,9 @@
ID, priority and nice values, memory footprint, and
percentage CPU usage. The following example shows multiple
httpd processes (with MPM worker and event) running on an
- Linux (Xen) system:
+ Linux (Xen) system:
</p>
-
+
<div class="example"><pre>top - 23:10:58 up 71 days, 6:14, 4 users, load average: 0.25, 0.53, 0.47
Tasks: 163 total, 1 running, 162 sleeping, 0 stopped, 0 zombie
Cpu(s): 11.6%us, 0.7%sy, 0.0%ni, 87.3%id, 0.4%wa, 0.0%hi, 0.0%si, 0.0%st
@@ -149,7 +149,7 @@ Swap: 4194296k total, 860584k used, 3333712k free, 1157552k cached
68 root 15 -5 0 0 0 S 0 0.0 0:06.28 kblockd/0
69 root 15 -5 0 0 0 S 0 0.0 0:00.04 kblockd/1
70 root 15 -5 0 0 0 S 0 0.0 0:00.04 kblockd/2</pre></div>
-
+
<p>Top is a wonderful tool even though it's slightly resource
intensive (when running, its own process is usually in the
top ten CPU gluttons). It is indispensable in determining
@@ -157,7 +157,7 @@ Swap: 4194296k total, 860584k used, 3333712k free, 1157552k cached
determining how many server processes you can run on your
machine. How to do this is described in <a href="#sizing-maxClients">sizing MaxClients</a>.
Top is, however, an interactive tool and running it
- continuously has few if any advantages.
+ continuously has few if any advantages.
</p>
<h4><a name="free" id="free">free
@@ -169,16 +169,16 @@ Swap: 4194296k total, 860584k used, 3333712k free, 1157552k cached
both with and without this cache. The free command can be
used to find out how much memory the operating system is
using, as described in the paragraph <a href="#sizing-maxClients">sizing MaxClients</a>.
- The output of free looks like this:
+ The output of free looks like this:
</p>
-
+
<div class="example"><pre>sctemme@brutus:~$ free
total used free shared buffers cached
Mem: 4026028 3901892 124136 0 253144 841044
-/+ buffers/cache: 2807704 1218324
Swap: 3903784 12540 3891244</pre></div>
-
+
<h4><a name="vmstat" id="vmstat">vmstat
</a></h4>
@@ -193,38 +193,38 @@ Swap: 3903784 12540 3891244</pre></div>
much memory is swapped in and out each second, the number
of processes currently running and sleeping, the number of
interrupts and context switches per second and the usage
- percentages of the CPU.
+ percentages of the CPU.
</p>
<p>
- The following is <code>vmstat</code> output of an idle server:
+ The following is <code>vmstat</code> output of an idle server:
</p>
-
-
+
+
<div class="example"><pre>[sctemme@GayDeceiver sctemme]$ vmstat 5 3
procs memory swap io system cpu
r b w swpd free buff cache si so bi bo in cs us sy id
0 0 0 0 186252 6688 37516 0 0 12 5 47 311 0 1 99
0 0 0 0 186244 6696 37516 0 0 0 16 41 314 0 0 100
0 0 0 0 186236 6704 37516 0 0 0 9 44 314 0 0 100</pre></div>
-
+
<p>And this is output of a server that is under a load of one
- hundred simultaneous connections fetching static content:
+ hundred simultaneous connections fetching static content:
</p>
-
+
<div class="example"><pre>[sctemme@GayDeceiver sctemme]$ vmstat 5 3
procs memory swap io system cpu
r b w swpd free buff cache si so bi bo in cs us sy id
1 0 1 0 162580 6848 40056 0 0 11 5 150 324 1 1 98
6 0 1 0 163280 6856 40248 0 0 0 66 6384 1117 42 25 32
11 0 0 0 162780 6864 40436 0 0 0 61 6309 1165 33 28 40</pre></div>
-
+
<p>The first line gives averages since the last reboot. The
subsequent lines give information for five second
intervals. The second argument tells vmstat to generate
- three reports and then exit.
+ three reports and then exit.
</p>
-
-
+
+
<h4><a name="se-toolkit" id="se-toolkit">SE Toolkit
</a></h4>
@@ -238,7 +238,7 @@ Swap: 3903784 12540 3891244</pre></div>
orange or red indicators when utilization of various parts
of the system rises above certain thresholds. Another
included script, Virtual Adrian, applies performance tuning
- metrics according to.
+ metrics according to.
</p>
<p>The SE Toolkit has drifted around for a while and has had
several owners since its inception. It seems that it has
@@ -248,20 +248,20 @@ Swap: 3903784 12540 3891244</pre></div>
code. SE Toolkit author Richard Pettit has started a new
company, Captive Metrics4 that plans to bring to market a
multiplatform monitoring tool built on the same principles
- as SE Toolkit, written in Java.
+ as SE Toolkit, written in Java.
</p>
-
-
+
+
<h4><a name="dtrace" id="dtrace">DTrace
</a></h4>
<p>Given that DTrace is available for Solaris, FreeBSD and OS
X, it might be worth exploring it. There's also
- mod_dtrace available for httpd.
+ mod_dtrace available for httpd.
</p>
-
-
+
+
<h4><a name="mod_status" id="mod_status">mod_status
</a></h4>
@@ -277,10 +277,10 @@ Swap: 3903784 12540 3891244</pre></div>
directive in your <code>httpd.conf</code>,
the <code class="module"><a href="../mod/mod_status.html">mod_status</a></code>
page will give you more information at the cost of a little
- extra work per request.
+ extra work per request.
</p>
-
-
+
+
<h3><a name="web-server-log-files" id="web-server-log-files">Web Server Log Files
@@ -295,10 +295,10 @@ Swap: 3903784 12540 3891244</pre></div>
from. Historical log file data can give you invaluable insight
into trends in access to your server, which allows you to
predict when your performance needs will overtake your server
- capacity.
+ capacity.
</p>
-
-
+
+
<h4><a name="ErrorLog" id="ErrorLog">Error Log
</a></h4>
@@ -311,7 +311,7 @@ Swap: 3903784 12540 3891244</pre></div>
redirected to the error logfile, so any error encountered
by httpd after it opens its logfiles will appear in this
log. This makes it good practice to review the error log
- frequently.
+ frequently.
</p>
<p>Before Apache httpd opens its logfiles, any errors will be
written to the stderr stream. If you start httpd manually,
@@ -323,7 +323,7 @@ Swap: 3903784 12540 3891244</pre></div>
file is usually a good bet. On Windows, early error
messages are written to the Applications Event Log, which
can be viewed through the Event Viewer in Administrative
- Tools.
+ Tools.
</p>
<p>
The Error Log is configured through the <code class="directive"><a href="../mod/core.html#errorlog">ErrorLog</a></code>
@@ -335,7 +335,7 @@ Swap: 3903784 12540 3891244</pre></div>
directive can also be used in virtual host containers. The
error log of a virtual host receives only log messages
specific to that virtual host, such as authentication
- failures and 'File not Found' errors.
+ failures and 'File not Found' errors.
</p>
<p>On a server that is visible to the Internet, expect to see a
lot of exploit attempt and worm attacks in the error log. A
@@ -345,12 +345,12 @@ Swap: 3903784 12540 3891244</pre></div>
port, regardless of which server is actually running or
what applications might be installed. You could block these
attempts using a firewall or <a href="http://www.modsecurity.org/">mod_security</a>,
- but this falls outside the scope of this discussion.
+ but this falls outside the scope of this discussion.
</p>
<p>
The <code class="directive"><a href="../mod/core.html#loglevel">LogLevel</a></code>
directive determines the level of detail included in the
- logs. There are eight log levels as described here:
+ logs. There are eight log levels as described here:
</p>
<table>
<tr>
@@ -430,18 +430,18 @@ Swap: 3903784 12540 3891244</pre></div>
not be run on debug, but increasing the level of detail in
the error log can be useful during troubleshooting.
Starting with 2.3.8 <code class="directive"><a href="../mod/core.html#loglevel">LogLevel</a></code>
- can be specified on a per module basis:
+ can be specified on a per module basis:
</p>
-
+
<pre class="prettyprint lang-config">LogLevel debug mod_ssl:warn</pre>
-
+
<p>
This puts all of the server in debug mode, except for
- <code class="module"><a href="../mod/mod_ssl.html">mod_ssl</a></code>, which tends to be very noisy.
+ <code class="module"><a href="../mod/mod_ssl.html">mod_ssl</a></code>, which tends to be very noisy.
</p>
-
-
+
+
<h4><a name="AccessLog" id="AccessLog">Access Log
</a></h4>
@@ -454,7 +454,7 @@ Swap: 3903784 12540 3891244</pre></div>
manual. This file exists by default for the main server and can be
configured per virtual host by using the <code class="directive"><a href="../mod/mod_log_config.html#transferlog">TransferLog</a></code>
or <code class="directive"><a href="../mod/mod_log_config.html#customlog">CustomLog</a></code>
- configuration directive.
+ configuration directive.
</p>
<p>The access logs can be analyzed with any of several free and
commercially available programs. Popular free analysis
@@ -462,10 +462,10 @@ Swap: 3903784 12540 3891244</pre></div>
be done offline so the web server machine is not burdened
by processing the log files. Most log analysis packages
understand the Common Log Format. The fields in the log
- lines are explained in in the following:
+ lines are explained in in the following:
</p>
-
-
+
+
<div class="example"><pre>195.54.228.42 - - [24/Mar/2007:23:05:11 -0400] "GET /sander/feed/ HTTP/1.1" 200 9747
64.34.165.214 - - [24/Mar/2007:23:10:11 -0400] "GET /sander/feed/atom HTTP/1.1" 200 9068
60.28.164.72 - - [24/Mar/2007:23:11:41 -0400] "GET / HTTP/1.0" 200 618
@@ -473,7 +473,7 @@ Swap: 3903784 12540 3891244</pre></div>
85.140.155.56 - - [24/Mar/2007:23:14:15 -0400] "GET /sander/2006/09/21/gore-tax-pollution/ HTTP/1.1" 200 15147
74.6.72.187 - - [24/Mar/2007:23:18:11 -0400] "GET /sander/2006/09/27/44/ HTTP/1.0" 200 14172
74.6.72.229 - - [24/Mar/2007:23:24:22 -0400] "GET /sander/2006/11/21/os-java/ HTTP/1.0" 200 13457</pre></div>
-
+
<table>
<tr>
<td>
@@ -564,7 +564,7 @@ Swap: 3903784 12540 3891244</pre></div>
</td>
</tr>
</table>
-
+
<h4><a name="rotating-log-files" id="rotating-log-files">Rotating Log Files
</a></h4>
@@ -576,17 +576,17 @@ Swap: 3903784 12540 3891244</pre></div>
file analysis should not be performed on files to which the
server is actively writing. Periodic logfile rotation helps
keep the analysis job manageable, and allows you to keep a
- closer eye on usage trends.
+ closer eye on usage trends.
</p>
<p>On unix systems, you can simply rotate logfiles by giving
the old file a new name using mv. The server will keep
writing to the open file even though it has a new name.
When you send a graceful restart signal to the server, it
will open a new logfile with the configured name. For
- example, you could run a script from cron like this:
+ example, you could run a script from cron like this:
</p>
-
-
+
+
<div class="example"><p><code>
APACHE=/usr/local/apache2<br />
HTTPD=$APACHE/bin/httpd<br />
@@ -594,7 +594,7 @@ Swap: 3903784 12540 3891244</pre></div>
$APACHE/logarchive/access_log-`date +%F`<br />
$HTTPD -k graceful
</code></p></div>
-
+
<p>This approach also works on Windows, just not as smoothly.
While the httpd process on your Windows server will keep
writing to the log file after it has been renamed, the
@@ -608,7 +608,7 @@ Swap: 3903784 12540 3891244</pre></div>
Windows Service has to perform will interrupt any requests
currently in progress, and the server is unavailable until
it is started again. Plan for this when you decide the
- timing of your restarts.
+ timing of your restarts.
</p>
<p>
A second approach is to use piped logs. From the
@@ -617,13 +617,13 @@ Swap: 3903784 12540 3891244</pre></div>
or <code class="directive"><a href="../mod/core.html#errorlog">ErrorLog
</a></code>
directives you can send the log data into any program using
- a pipe character (<code>|</code>). For instance:
+ a pipe character (<code>|</code>). For instance:
</p>
-
+
<div class="example"><p><code>CustomLog "|/usr/local/apache2/bin/rotatelogs
/var/log/access_log 86400" common
</code></p></div>
-
+
<p>The program on the other end of the pipe will receive the
Apache log data on its stdin stream, and can do with this
data whatever it wants. The rotatelogs program that comes
@@ -631,10 +631,10 @@ Swap: 3903784 12540 3891244</pre></div>
time elapsed or the amount of data written, and leaves the
old log files with a timestamp suffix to its name. This
method for rotating logfiles works well on unix platforms,
- but is currently broken on Windows.
+ but is currently broken on Windows.
</p>
-
-
+
+
<h4><a name="logging-and-performance" id="logging-and-performance">Logging and Performance
</a></h4>
@@ -647,7 +647,7 @@ Swap: 3903784 12540 3891244</pre></div>
the server log files: the access patterns are very
different. Retrieving content from disk is a read operation
in a fairly random pattern, and log files are written to
- disk sequentially.
+ disk sequentially.
</p>
<p>
Do not run a production server with your error <code class="directive"><a href="../mod/core.html#loglevel">LogLevel</a></code>
@@ -655,7 +655,7 @@ Swap: 3903784 12540 3891244</pre></div>
information to be written to the error log, including, in
the case of SSL access, complete dumps of BIO read and
write operations. The performance implications are
- significant: use the default warn level instead.
+ significant: use the default warn level instead.
</p>
<p>If your server has more than one virtual host, you may give
each virtual host a separate access logfile. This makes it
@@ -676,10 +676,10 @@ Swap: 3903784 12540 3891244</pre></div>
directive to have Apache collect several log lines in
memory before writing them to disk. This might yield better
performance, but could affect the order in which the
- server's log is written.
+ server's log is written.
</p>
-
-
+
+
<h3><a name="generating-a-test-load" id="generating-a-test-load">Generating A Test Load
@@ -689,7 +689,7 @@ Swap: 3903784 12540 3891244</pre></div>
performance under realistic operating circumstances. Besides
commercial packages such as <a href="http://learnloadrunner.com/">LoadRunner</a>
,there are a number of freely available tools to generate a
- test load against your web server.
+ test load against your web server.
</p>
<ul>
<li>Apache ships with a test program called ab, short for
@@ -697,20 +697,20 @@ Swap: 3903784 12540 3891244</pre></div>
repeatedly asking for the same file in rapid succession.
You can specify a number of concurrent connections and have
the program run for either a given amount of time or a
- specified number of requests.
+ specified number of requests.
</li>
<li>Another freely available load generator is http load11 .
This program works with a URL file and can be compiled with
- SSL support.
+ SSL support.
</li>
<li>The Apache Software Foundation offers a tool named flood12
. Flood is a fairly sophisticated program that is
- configured through an XML file.
+ configured through an XML file.
</li>
<li>Finally, JMeter13 , a Jakarta subproject, is an all-Java
load-testing tool. While early versions of this application
were slow and difficult to use, the current version 2.1.1
- seems to be versatile and useful.
+ seems to be versatile and useful.
</li>
<li>
<p>ASF external projects, that have proven to be quite
@@ -723,16 +723,16 @@ Swap: 3903784 12540 3891244</pre></div>
affect the server's response. Also, any data traffic you
generate may be charged against your monthly traffic allowance.
</p>
-
-
+
+
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="configuring-for-performance" id="configuring-for-performance">Configuring for Performance
</a></h2>
-
-
+
+
<h3><a name="apache-configuration" id="apache-configuration">Httpd Configuration
</a></h3>
@@ -750,7 +750,7 @@ Swap: 3903784 12540 3891244</pre></div>
multiple request handling threads within each child process. In
2.4 MPMs are no longer hard-wired. They too can be exchanged
via <code class="directive"><a href="../mod/mod_so.html#loadmodule">LoadModule</a></code>.
- The default MPM in 2.4 is the event MPM.
+ The default MPM in 2.4 is the event MPM.
</p>
<p>The maximum number of workers, be they pre-forked child
processes or threads within a process, is an indication of how
@@ -760,7 +760,7 @@ Swap: 3903784 12540 3891244</pre></div>
the maximum number of workers is running, the machine
doesn't hit a hard limit beyond which clients will be
denied access. However, once requests start backing up, system
- performance is likely to degrade.
+ performance is likely to degrade.
</p>
<p>Finally, if the httpd server in question is not executing any third-party
code, via <code>mod_php</code>, <code>mod_perl</code> or similar,
@@ -768,8 +768,8 @@ Swap: 3903784 12540 3891244</pre></div>
for situations where httpd serves as a thin layer between clients and
backend servers doing the real job, such as a proxy or cache.
</p>
-
-
+
+
<h4><a name="MaxClients" id="MaxClients">MaxClients
</a></h4>
@@ -786,10 +786,10 @@ Swap: 3903784 12540 3891244</pre></div>
number of processes is configurable through the <code>
ServerLimit
</code>
- directive.
+ directive.
</p>
-
-
+
+
<h4><a name="spinning-threads" id="spinning-threads">Spinning Threads
</a></h4>
@@ -811,8 +811,8 @@ Swap: 3903784 12540 3891244</pre></div>
value downwards until it is an even factor of
<code>MaxClients</code>.
</p>
-
-
+
+
<h4><a name="sizing-maxClients" id="sizing-maxClients">Sizing MaxClients
</a></h4>
@@ -822,16 +822,16 @@ Swap: 3903784 12540 3891244</pre></div>
your system gets so overloaded that it needs to heavily
swap core memory out to disk, performance will degrade
quickly. The formula for determining <code class="directive"><a href="../mod/mpm_common.html#maxrequestworkers">MaxClients</a></code>
- is fairly simple:
+ is fairly simple:
</p>
-
+
<div class="example"><p><code>
total RAM - RAM for OS - RAM for external programs<br />
MaxClients =
-------------------------------------------------------<br />
RAM per httpd process
</code></p></div>
-
+
<p>The various amounts of memory allocated for the OS, external
programs and the httpd processes is best determined by
observation: use the top and free commands described above
@@ -839,7 +839,7 @@ Swap: 3903784 12540 3891244</pre></div>
server running. You can also determine the footprint of a
typical web server process from top: most top
implementations have a Resident Size (RSS) column and a
- Shared Memory column.
+ Shared Memory column.
</p>
<p>The difference between these two is the amount of memory
per-process. The shared segment really exists only once and
@@ -849,7 +849,7 @@ Swap: 3903784 12540 3891244</pre></div>
depends heavily on the number and kind of modules you use.
The best approach to use in determining this need is to
generate a typical test load against your web site and see
- how large the httpd processes become.
+ how large the httpd processes become.
</p>
<p>The RAM for external programs parameter is intended mostly
for CGI programs and scripts that run outside the web
@@ -869,10 +869,10 @@ Swap: 3903784 12540 3891244</pre></div>
to fork additional child processes, so a higher <code>
MaxClients
</code>
- value may actually be a disadvantage.
+ value may actually be a disadvantage.
</p>
-
-
+
+
<h4><a name="selecting-your-mpm" id="selecting-your-mpm">Selecting your MPM
</a></h4>
@@ -887,7 +887,7 @@ Swap: 3903784 12540 3891244</pre></div>
sense. On Linux, the threading implementation actually uses
one process for each thread. Linux processes are relatively
lightweight, but it means that a threaded MPM offers less
- of a performance advantage than in other environments.
+ of a performance advantage than in other environments.
</p>
<p>Running a threaded MPM can cause stability problems in some
situations For instance, should a child process of a
@@ -906,10 +906,10 @@ Swap: 3903784 12540 3891244</pre></div>
cannot guarantee that all of these are thread-safe. The
good news is that if you are running Apache on Linux, you
can run PHP in the preforked MPM without fear of losing too
- much performance relative to the threaded option.
+ much performance relative to the threaded option.
</p>
-
-
+
+
<h4><a name="spinning-locks" id="spinning-locks">Spinning Locks
</a></h4>
@@ -931,10 +931,10 @@ Swap: 3903784 12540 3891244</pre></div>
this time, the parent process may decide to terminate some
children based on its <code>MaxSpareServers
</code>
- directive.
+ directive.
</p>
-
-
+
+
<h4><a name="the-thundering-herd" id="the-thundering-herd">The Thundering Herd
</a></h4>
@@ -942,7 +942,7 @@ Swap: 3903784 12540 3891244</pre></div>
<p>The function of the 'accept mutex' (as this
inter-process lock is called) is to keep request reception
moving along in an orderly fashion. If the lock is absent,
- the server may exhibit the Thundering Herd syndrome.
+ the server may exhibit the Thundering Herd syndrome.
</p>
<p>Consider an American Football team poised on the line of
scrimmage. If the football players were Apache processes
@@ -951,7 +951,7 @@ Swap: 3903784 12540 3891244</pre></div>
would have to lumber back to the line for the next snap. In
this metaphor, the accept mutex acts as the quarterback,
delivering the connection "ball" to the
- appropriate player process.
+ appropriate player process.
</p>
<p>Moving this much information around is obviously a lot of
work, and, like a smart person, a smart web server tries to
@@ -964,7 +964,7 @@ Swap: 3903784 12540 3891244</pre></div>
refrain from using an accept mutex. If you run with
multiple listeners (for instance because you have a virtual
host serving SSL requests), it will activate the accept
- mutex to avoid internal conflicts.
+ mutex to avoid internal conflicts.
</p>
<p>
You can manipulate the accept mutex with the <code>
@@ -976,15 +976,15 @@ Swap: 3903784 12540 3891244</pre></div>
all are available on every platform, and their availability
also depends on compile-time settings. The various locking
mechanisms may place specific demands on system resources:
- manipulate them with care.
+ manipulate them with care.
</p>
<p>There is no compelling reason to disable the accept mutex.
Apache automatically recognizes the single listener
situation described above and knows if it is safe to run
- without mutex on your platform.
+ without mutex on your platform.
</p>
-
-
+
+
<h3><a name="tuning-the-operating-system" id="tuning-the-operating-system">Tuning the Operating System
@@ -996,10 +996,10 @@ Swap: 3903784 12540 3891244</pre></div>
are pretty well adjusted straight out of the box and there is
not a lot that needs to be done to make them perform optimally.
However, there are a few things that an administrator can do to
- improve performance.
+ improve performance.
</p>
-
-
+
+
<h4><a name="ram-and-swap-space" id="ram-and-swap-space">RAM and Swap Space
</a></h4>
@@ -1012,7 +1012,7 @@ Swap: 3903784 12540 3891244</pre></div>
virtual hosts-also tends to inflate the process footprint.
Having ample RAM allows you to run Apache with more child
processes, which allows the server to process more
- concurrent requests.
+ concurrent requests.
</p>
<p>While the various platforms treat their virtual memory in
different ways, it is never a good idea to run with less
@@ -1021,7 +1021,7 @@ Swap: 3903784 12540 3891244</pre></div>
don't have disk space available and run out of
swappable memory, your machine grinds to a halt. This can
crash your box, requiring a physical reboot for which your
- hosting facility may charge you.
+ hosting facility may charge you.
</p>
<p>Also, such an outage naturally occurs when you least want
it: when the world has found your website and is beating a
@@ -1031,7 +1031,7 @@ Swap: 3903784 12540 3891244</pre></div>
and back, but when the load decreases the system should
recover. Remember, you still have <code>MaxClients
</code>
- to keep things in hand.
+ to keep things in hand.
</p>
<p>Most unix-like operating systems use designated disk
partitions for swap space. When a system starts up it finds
@@ -1042,7 +1042,7 @@ Swap: 3903784 12540 3891244</pre></div>
installing the operating system, be sure to allocate enough
swap space to accommodate eventual RAM upgrades.
Reassigning disk space on a running system is a cumbersome
- process.
+ process.
</p>
<p>Plan for available hard drive swap space of at least twice
your amount of RAM, perhaps up to four times in situations
@@ -1056,29 +1056,29 @@ Swap: 3903784 12540 3891244</pre></div>
</code>
or <code>swap
</code>
- programs.
+ programs.
</p>
-
-
+
+
<h4><a name="ulimit-files-and-processes" id="ulimit-files-and-processes">ulimit: Files and Processes
</a></h4>
<p>Given a machine with plenty of RAM and processor capacity,
you can run hundreds of Apache processes if necessary. . .
- and if your kernel allows it.
+ and if your kernel allows it.
</p>
<p>Consider a situation in which several hundred web servers
are running; if some of these need to spawn CGI processes,
- the maximum number of processes would occur quickly.
+ the maximum number of processes would occur quickly.
</p>
- <p>However, you can change this limit with the command
+ <p>However, you can change this limit with the command
</p>
-
+
<div class="example"><p><code>
ulimit [-H|-S] -u [newvalue]
</code></p></div>
-
+
<p>This must be changed before starting the server, since the
new value will only be available to the current shell and
programs started from it. In newer Linux kernels the
@@ -1092,28 +1092,28 @@ Swap: 3903784 12540 3891244</pre></div>
</code>
:
</p>
-
+
<div class="example"><p><code>
limit [-h] maxproc [newvalue]
</code></p></div>
-
+
<p>Similarly, the kernel may limit the number of open files per
process. This is generally not a problem for pre-forked
servers, which just handle one request at a time per
process. Threaded servers, however, serve many requests per
process and much more easily run out of available file
descriptors. You can increase the maximum number of open
- files per process by running the
+ files per process by running the
</p>
-
+
<div class="example"><p><code>ulimit -n [newvalue]
</code></p></div>
-
+
<p>command. Once again, this must be done prior to starting
- Apache.
+ Apache.
</p>
-
-
+
+
<h4><a name="setting-user-limits-on-system-startup" id="setting-user-limits-on-system-startup">Setting User Limits on System Startup
</a></h4>
@@ -1126,15 +1126,15 @@ Swap: 3903784 12540 3891244</pre></div>
explaining the options. To enable this, make sure that the
file <code>/etc/pam.d/login
</code>
- contains the line
+ contains the line
</p>
-
+
<div class="example"><p><code>session required /lib/security/pam_limits.so
</code></p></div>
-
+
<p>All items can have a 'soft' and a 'hard'
limit: the first is the default setting and the second the
- maximum value for that item.
+ maximum value for that item.
</p>
<p>
In FreeBSD's <code>/etc/login.conf
@@ -1150,27 +1150,27 @@ Swap: 3903784 12540 3891244</pre></div>
boot time. These are the same tunables that can be set with
the <code>mdb</code>
kernel debugger during run time. The soft and hard limit
- corresponding to ulimit -u can be set via:
+ corresponding to ulimit -u can be set via:
</p>
-
+
<div class="example"><p><code>
set rlim_fd_max=65536<br />
set rlim_fd_cur=2048
</code></p></div>
-
+
<p>Solaris calculates the maximum number of allowed processes
per user (<code>maxuprc</code>) based on the total amount
available memory on the system (<code>maxusers</code>).
- You can review the numbers with
+ You can review the numbers with
</p>
-
+
<div class="example"><p><code>sysdef -i | grep maximum
</code></p></div>
-
- <p>but it is not recommended to change them.
+
+ <p>but it is not recommended to change them.
</p>
-
-
+
+
<h4><a name="turn-off-unused-services-and-modules" id="turn-off-unused-services-and-modules">Turn Off Unused Services and Modules
</a></h4>
@@ -1179,19 +1179,19 @@ Swap: 3903784 12540 3891244</pre></div>
services turned on by default. You probably need few of
them. For example, your web server does not need to be
running sendmail, nor is it likely to be an NFS server,
- etc. Turn them off.
+ etc. Turn them off.
</p>
<p>On Red Hat Linux, the chkconfig tool will help you do this
from the command line. On Solaris systems <code>svcs</code>
and <code>svcadm</code>
will show which services are enabled and disable them
- respectively.
+ respectively.
</p>
<p>In a similar fashion, cast a critical eye on the Apache
modules you load. Most binary distributions of Apache
httpd, and pre-installed versions that come with Linux
distributions, have their modules enabled through the
- <code class="directive">LoadModule</code> directive.
+ <code class="directive">LoadModule</code> directive.
</p>
<p>Unused modules may be culled: if you don't rely on
their functionality and configuration directives, you can
@@ -1200,10 +1200,10 @@ Swap: 3903784 12540 3891244</pre></div>
lines. Read the documentation on each module's
functionality before deciding whether to keep it enabled.
While the performance overhead of an unused module is
- small, it's also unnecessary.
+ small, it's also unnecessary.
</p>
-
-
+
+
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
@@ -1216,7 +1216,7 @@ Swap: 3903784 12540 3891244</pre></div>
Static content consists of simple filespages, images, etc.-on disk
that are very efficiently served. Many operating systems also
automatically cache the contents of frequently accessed files in
- memory.
+ memory.
</p>
<p>Processing dynamic requests, on the contrary, can be much more
involved. Running CGI scripts, handing off requests to an external
@@ -1224,10 +1224,10 @@ Swap: 3903784 12540 3891244</pre></div>
significant latency and processing load to a busy web server. Under
many circumstances, performance can be improved by turning popular
dynamic requests into static requests. In this section, two
- approaches to this will be discussed.
+ approaches to this will be discussed.
</p>
-
-
+
+
<h3><a name="making-popular-pages-static" id="making-popular-pages-static">Making Popular Pages Static
</a></h3>
@@ -1241,33 +1241,33 @@ Swap: 3903784 12540 3891244</pre></div>
they are served the pre-rendered page. Queries for, say, yellow
roses will be generated directly from the database. The
mod_rewrite module included with Apache is a great tool to
- implement these substitutions.
+ implement these substitutions.
</p>
-
-
+
+
<h4><a name="example-a-statically-rendered-blog" id="example-a-statically-rendered-blog">Example: A Statically Rendered Blog
</a></h4>
-
+
<p>Blosxom is a lightweight web log package that runs as a CGI.
It is written in Perl and uses plain text files for entry
input. Besides running as CGI, Blosxom can be run from the
command line to pre-render blog pages. Pre-rendering pages
to static HTML can yield a significant performance boost in
the event that large numbers of people actually start
- reading your blog.
+ reading your blog.
</p>
<p>To run blosxom for static page generation, edit the CGI
script according to the documentation. Set the $static dir
variable to the <code class="directive">DocumentRoot</code>
of the web server, and run the script from the command line
- as follows:
+ as follows:
</p>
-
+
<div class="example"><p><code>$ perl blosxom.cgi -password='whateveryourpassword'
</code></p></div>
-
+
<p>This can be run periodically from Cron, after you upload
content, etc. To make Apache substitute the statically
rendered pages for the dynamic content, we'll use
@@ -1277,9 +1277,9 @@ Swap: 3903784 12540 3891244</pre></div>
to the configure command. Many binary distributions of
Apache come with <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite </a></code> included. The following is an
example of an Apache virtual host that takes advantage of
- pre-rendered blog pages:
+ pre-rendered blog pages:
</p>
-
+
<pre class="prettyprint lang-config">Listen *:8001
&lt;VirtualHost *:8001&gt;
ServerName blog.sandla.org:8001
@@ -1289,11 +1289,11 @@ Swap: 3903784 12540 3891244</pre></div>
Options +Indexes
Require all granted
RewriteEngine on
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteRule ^(.*)$ /cgi-bin/blosxom.cgi/$1 [L,QSA]
+ RewriteCond "%{REQUEST_FILENAME}" "!-f"
+ RewriteCond "%{REQUEST_FILENAME}" "!-d"
+ RewriteRule "^(.*)$" "/cgi-bin/blosxom.cgi/$1" [L,QSA]
&lt;/Directory&gt;
- RewriteLog /home/sctemme/inst/blog/httpd/logs/rewrite_log
+ RewriteLog "/home/sctemme/inst/blog/httpd/logs/rewrite_log"
RewriteLogLevel 9
ErrorLog /home/sctemme/inst/blog/httpd/logs/error_log
LogLevel debug
@@ -1305,7 +1305,7 @@ Swap: 3903784 12540 3891244</pre></div>
&lt;/Directory&gt;
&lt;/VirtualHost&gt;</pre>
-
+
<p>
The <code class="directive">RewriteCond</code>
and <code class="directive">RewriteRule</code>
@@ -1322,10 +1322,10 @@ Swap: 3903784 12540 3891244</pre></div>
hides the Blosxom CGI from the user-visible URL in their
Location bar. mod_rewrite is a fantastically powerful and
versatile module: investigate it to arrive at a
- configuration that is best for your situation.
+ configuration that is best for your situation.
</p>
-
-
+
+
<h3><a name="caching-content-with-mod_cache" id="caching-content-with-mod_cache">Caching Content With mod_cache
@@ -1342,12 +1342,12 @@ Swap: 3903784 12540 3891244</pre></div>
server systems will have more disk available than memory, and
it's good to note that some operating system kernels cache
frequently accessed disk content transparently in memory, so
- replicating this in the server is not very useful.
+ replicating this in the server is not very useful.
</p>
<p>To enable efficient content caching and avoid presenting the
user with stale or invalid content, the application that
generates the actual content has to send the correct response
- headers. Without headers like <code>Etag:</code>,
+ headers. Without headers like <code>Etag:</code>,
<code>Last-Modified:</code> or <code>Expires:</code>,
<code class="module"><a href="../mod/mod_cache.html">mod_cache</a></code> can not make the right decision on whether to cache
the content, serve it from cache or leave it alone. When
@@ -1358,10 +1358,10 @@ Swap: 3903784 12540 3891244</pre></div>
option <code>--enable-cache[=shared]</code>
to the configure script. If you use a binary distribution of
Apache httpd, or it came with your port or package collection,
- it may have <code class="module"><a href="../mod/mod_cache.html">mod_cache</a></code> already included.
+ it may have <code class="module"><a href="../mod/mod_cache.html">mod_cache</a></code> already included.
</p>
-
-
+
+
<h4><a name="example-wiki" id="example-wiki">Example: wiki.apache.org
</a></h4>
@@ -1384,7 +1384,7 @@ Swap: 3903784 12540 3891244</pre></div>
enabled with the following configuration snippet in
<code>httpd.conf</code>:
</p>
-
+
<pre class="prettyprint lang-config">CacheRoot /raid1/cacheroot
CacheEnable disk /
# A page modified 100 minutes ago will expire in 10 minutes
@@ -1392,7 +1392,7 @@ CacheLastModifiedFactor .1
# Always check again after 6 hours
CacheMaxExpire 21600</pre>
-
+
<p>This configuration will try to cache any and all content
within its virtual host. It will never cache content for
more than six hours (the <code class="directive"><a href="../mod/mod_cache.html#cachemaxexpire">CacheMaxExpire</a></code>
@@ -1402,7 +1402,7 @@ CacheMaxExpire 21600</pre>
header. The computation using <code class="directive"><a href="../mod/mod_cache.html#cachelastmodifiedfactor">CacheLastModifiedFactor</a></code>
is based on the assumption that if a page was recently
modified, it is likely to change again in the near future
- and will have to be re-cached.
+ and will have to be re-cached.
</p>
<p>
Do note that it can pay off to <em>disable</em>
@@ -1415,20 +1415,20 @@ CacheMaxExpire 21600</pre>
TCP packet). For resources larger than 1k it might prove
CPU expensive to calculate the header for each request.
Unfortunately there does currently not exist a way to cache
- these headers.
+ these headers.
</p>
<pre class="prettyprint lang-config">&lt;FilesMatch "\.(jpe?g|png|gif|js|css|x?html|xml)"&gt;
FileETag None
&lt;/FilesMatch&gt;</pre>
-
+
<p>
This will disable the generation of the <code>ETag:</code>
header for most static resources. The server does not
- calculate these headers for dynamic resources.
+ calculate these headers for dynamic resources.
</p>
-
-
+
+
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>