VLINK="#000080"
ALINK="#FF0000"
>
-<H1>Apache Performance Notes</H1>
+<!--#include virtual="header.html" -->
+<H1 align="center">Apache Performance Notes</H1>
<P>Author: Dean Gaudet
-<H3>Introduction</H3>
+<ul>
+<li><a href="#introduction">Introduction</a></li>
+<li><a href="#hardware">Hardware and Operating System Issues</a></li>
+<li><a href="#runtime">Run-Time Configuration Issues</a></li>
+<li><a href="#compiletime">Compile-Time Configuration Issues</a></li>
+<li>Appendixes
+ <ul>
+ <li><a href="#trace">Detailed Analysis of a Trace</a></li>
+ <li><a href="#patches">Patches Available</a></li>
+ <li><a href="#preforking">The Pre-Forking Model</a></li>
+ </ul></li>
+</ul>
+
+<hr>
+
+<H3><a name="introduction">Introduction</A></H3>
<P>Apache is a general webserver, which is designed to be correct first, and
fast second. Even so, its performance is quite satisfactory. Most
sites have less than 10Mbits of outgoing bandwidth, which Apache can
it does some things which slow it down.
<P>Note that this is tailored towards Apache 1.3 on Unix. Some of it applies
-to Apache on NT. Apache on NT has not been tuned for performance yet,
+to Apache on NT. Apache on NT has not been tuned for performance yet;
in fact it probably performs very poorly because NT performance requires
a different programming model.
-<H3>Hardware and Operating System Issues</H3>
+<hr>
+
+<H3><a name="hardware">Hardware and Operating System Issues</a></H3>
<P>The single biggest hardware issue affecting webserver performance
is RAM. A webserver should never ever have to swap, swapping increases
kernels up through 1994 and even 1995. Good choices include
recent FreeBSD, and Linux.
-<H3>Run-Time Configuration Issues</H3>
+<hr>
+
+<H3><a name="runtime">Run-Time Configuration Issues</a></H3>
<H4>HostnameLookups</H4>
<P>Prior to Apache 1.3, <CODE>HostnameLookups</CODE> defaulted to On.
<A HREF="http://www.research.digital.com/wrl/techreports/abstracts/95.4.html"
>most of the benefits are lost</A>.
-<H3>Compile-Time Configuration Issues</H3>
+<hr>
+
+<H3><a name="compiletime">Compile-Time Configuration Issues</a></H3>
<H4>mod_status and ExtendedStatus On</H4>
for (;;) {
fd_set accept_fds;
- FD_ZERO (&accept_fds);
+ FD_ZERO (&accept_fds);
for (i = first_socket; i <= last_socket; ++i) {
- FD_SET (i, &accept_fds);
+ FD_SET (i, ∓accept_fds);
}
- rc = select (last_socket+1, &accept_fds, NULL, NULL, NULL);
+ rc = select (last_socket+1, &accept_fds, NULL, NULL, NULL);
if (rc < 1) continue;
new_connection = -1;
for (i = first_socket; i <= last_socket; ++i) {
for (;;) {
fd_set accept_fds;
- FD_ZERO (&accept_fds);
+ FD_ZERO (&accept_fds);
for (i = first_socket; i <= last_socket; ++i) {
- FD_SET (i, &accept_fds);
+ FD_SET (i, &accept_fds);
}
- rc = select (last_socket+1, &accept_fds, NULL, NULL, NULL);
+ rc = select (last_socket+1, &accept_fds, NULL, NULL, NULL);
if (rc < 1) continue;
new_connection = -1;
for (i = first_socket; i <= last_socket; ++i) {
- if (FD_ISSET (i, &accept_fds)) {
+ if (FD_ISSET (i, &accept_fds)) {
new_connection = accept (i, NULL, NULL);
if (new_connection != -1) break;
}
select (s for reading, 2 second timeout);
if (error) break;
if (s is ready for reading) {
- if (read (s, junk_buffer, sizeof (junk_buffer)) <= 0) {
+ if (read (s, junk_buffer, sizeof (junk_buffer)) <= 0) {
break;
}
/* just toss away whatever is here */
This will save RAM that's allocated only for supporting dynamically
loaded modules.
-<H3>Appendix: Detailed Analysis of a Trace</H3>
+<hr>
+
+<H3><a name="trace">Appendix: Detailed Analysis of a Trace</a></H3>
Here is a system call trace of Apache 1.3 running on Linux. The run-time
configuration file is essentially the default plus:
<CODE>Timeout</CODE>.
<P>It may even be the case that <CODE>mmap</CODE> isn't
-used on your architecture, if so then defining <CODE>USE_MMAP_FILES</CODE>
+used on your architecture; if so then defining <CODE>USE_MMAP_FILES</CODE>
and <CODE>HAVE_MMAP</CODE> might work (if it works then report back to us).
<P>Apache does its best to avoid copying bytes around in memory. The
are buffered before writing. At no time does it split a log entry
across a <CODE>PIPE_BUF</CODE> boundary because those writes may not
be atomic. (<EM>i.e.</EM>, entries from multiple children could become mixed together).
-The code does it best to flush this buffer when a child dies.
+The code does its best to flush this buffer when a child dies.
<P>The lingering close code causes four system calls:
cost of removing some functionality.
</UL>
-<H3>Appendix: The Pre-Forking Model</H3>
+<H3><a name="preforking">Appendix: The Pre-Forking Model</a></H3>
<P>Apache (on Unix) is a <EM>pre-forking</EM> model server. The
<EM>parent</EM> process is responsible only for forking <EM>child</EM>
1.3 is multithreaded on NT. There have been at least two other experimental
implementations of threaded Apache, one using the 1.3 code base on DCE,
and one using a custom user-level threads package and the 1.0 code base;
-neither is available publically. There is also an experimental port of
+neither is publicly available. There is also an experimental port of
Apache 1.3 to <A HREF="http://www.mozilla.org/docs/refList/refNSPR/">
Netscape's Portable Run Time</A>, which
<A HREF="http://www.arctic.org/~dgaudet/apache/2.0/">is available</A>
can continue to support the pre-forking model, and also support various
threaded models.
+<!--#include virtual="footer.html" -->
</BODY>
</HTML>