From 4fbef92a4a152bcdd6011c000bbccdabd3fb0a5c Mon Sep 17 00:00:00 2001
From: Mike Rumph Run the latest stable release and patchlevel of the
+ Run the latest stable release and patch level of the
operating system that you choose. Many OS suppliers have
introduced significant performance improvements to their
TCP stacks and thread libraries in recent years. Wherever in your URL-space you do not have an top
, and divide this into your total available memory,
@@ -74,7 +74,7 @@
Options
FollowSymLinks
, or you do have an Options
- SymLinksIfOwnerMatch
Apache will have to issue extra
- system calls to check up on symlinks. One extra call per
- filename component. For example, if you had:
/www/htdocs/index.html
. The results of these
lstats
are never cached, so they will occur on
every single request. If you really desire the symlinks
- security checking you can do something like this:
+ security checking, you can do something like this:
This at least avoids the extra checks for the
Wherever in your URL-space you allow overrides (typically
- .htaccess
files) Apache will attempt to open
+ .htaccess
files), Apache will attempt to open
.htaccess
for each filename component. For
example,
If at all possible, avoid content-negotiation if you're +
If at all possible, avoid content negotiation, if you're really interested in every last ounce of performance. In practice the benefits of negotiation outweigh the performance penalties. There's one case where you can speed up the server. @@ -262,7 +262,7 @@ DocumentRoot "/www/htdocs" determined by reading this single file, rather than having to scan the directory for files.
-If your site needs content negotiation consider using +
If your site needs content negotiation, consider using
type-map
files, rather than the Options
MultiViews
directive to accomplish the negotiation. See the
Content Negotiation
@@ -277,7 +277,7 @@ DocumentRoot "/www/htdocs"
In situations where Apache 2.x needs to look at the contents
of a file being delivered--for example, when doing server-side-include
- processing--it normally memory-maps the file if the OS supports
+ processing--it normally memory-maps the file, if the OS supports
some form of mmap(2)
.
On some platforms, this memory-mapping improves performance. @@ -313,7 +313,7 @@ DocumentRoot "/www/htdocs"
In situations where Apache 2.x can ignore the contents of the file
to be delivered -- for example, when serving static file content --
- it normally uses the kernel sendfile support the file if the OS
+ it normally uses the kernel sendfile support for the file, if the OS
supports the sendfile(2)
operation.
On most platforms, using sendfile improves performance by eliminating
@@ -356,14 +356,14 @@ DocumentRoot "/www/htdocs"
setting. So a server being accessed by 100 simultaneous
clients, using the default 5
would take on
- the order 95 seconds to spawn enough children to handle
+ the order of 95 seconds to spawn enough children to handle
the load. This works fine in practice on real-life servers,
- because they aren't restarted frequently. But does really
+ because they aren't restarted frequently. But it does really
poorly on benchmarks which might only run for ten minutes.
The one-per-second rule was implemented in an effort to
avoid swamping the machine with the startup of new children. If
- the machine is busy spawning children it can't service
+ the machine is busy spawning children, it can't service
requests. But it has such a drastic effect on the perceived
performance of Apache that it had to be replaced. As of Apache
1.3, the code will relax the one-per-second rule. It will spawn
@@ -380,7 +380,7 @@ DocumentRoot "/www/htdocs"
>StartServers knobs. When more than 4 children are
spawned per second, a message will be emitted to the
Related to process creation is process death induced by the
@@ -556,7 +556,7 @@ DocumentRoot "/www/htdocs"
This section has not been fully updated
@@ -569,7 +569,7 @@ DocumentRoot "/www/htdocs"
your web server uses multiple select(2)
. select(2)
indicates that a
socket has zero or at least one connection
waiting on it. Apache's model includes multiple children, and
@@ -607,12 +607,12 @@ DocumentRoot "/www/htdocs"
time, and so multiple children will block at
select
when they are in between requests. All
those blocked children will awaken and return from
- select
when a single request appears on any socket
- (the number of children which awaken varies depending on the
- operating system and timing issues). They will all then fall
+ select
when a single request appears on any socket.
+ (The number of children which awaken varies depending on the
+ operating system and timing issues.) They will all then fall
down into the loop and try to accept
the
connection. But only one will succeed (assuming there's still
- only one connection ready), the rest will be blocked
+ only one connection ready). The rest will be blocked
in accept
. This effectively locks those children
into serving requests from that one socket and no other
sockets, and they'll be stuck there until enough new requests
@@ -631,9 +631,9 @@ DocumentRoot "/www/htdocs"
accomplishing nothing. Meanwhile none of those children are
servicing requests that occurred on other sockets until they
get back up to the select
again. Overall this
- solution does not seem very fruitful unless you have as many
- idle CPUs (in a multiprocessor box) as you have idle children,
- not a very likely situation.
Another solution, the one used by Apache, is to serialize entry into the inner loop. The loop looks like this @@ -686,7 +686,7 @@ DocumentRoot "/www/htdocs"
Another solution that has been considered but never
implemented is to partially serialize the loop -- that is, let
in a certain number of processes. This would only be of
- interest on multiprocessor boxes where it's possible multiple
+ interest on multiprocessor boxes where it's possible that multiple
children could run simultaneously, and the serialization
actually doesn't take advantage of the full bandwidth. This is
a possible area of future investigation, but priority remains
@@ -701,14 +701,14 @@ DocumentRoot "/www/htdocs"
The above is fine and dandy for multiple socket servers, but
what about single socket servers? In theory they shouldn't
- experience any of these same problems because all children can
+ experience any of these same problems, because all children can
just block in accept(2)
until a connection
arrives, and no starvation results. In practice this hides
- almost the same "spinning" behaviour discussed above in the
+ almost the same "spinning" behavior discussed above in the
non-blocking solution. The way that most TCP stacks are
implemented, the kernel actually wakes up all processes blocked
in accept
when a single connection arrives. One of
@@ -716,7 +716,7 @@ DocumentRoot "/www/htdocs"
the rest spin in the kernel and go back to sleep when they
discover there's no connection for them. This spinning is
hidden from the user-land code, but it's there nonetheless.
- This can result in the same load-spiking wasteful behaviour
+ This can result in the same load-spiking wasteful behavior
that a non-blocking solution to the multiple sockets case
can.SINGLE_LISTEN_UNSERIALIZED_ACCEPT
and then
+ serialization, you can define
+ SINGLE_LISTEN_UNSERIALIZED_ACCEPT
, and then
single-socket servers will not serialize at all.
When this feature was added to Apache it caused a flurry of
- problems on various versions of Unix because of a
- shortsightedness. The TCP specification does not state that the
- FIN_WAIT_2
state has a timeout, but it doesn't prohibit it.
+ protocol, it needs to shut down each direction of the
+ communication independently. (Recall that a TCP connection is
+ bi-directional, each half is independent of the other.)
When this feature was added to Apache, it caused a flurry of
+ problems on various versions of Unix because of shortsightedness.
+ The TCP specification does not state that the FIN_WAIT_2
+ state has a timeout, but it doesn't prohibit it.
On systems without the timeout, Apache 1.2 induces many sockets
stuck forever in the FIN_WAIT_2
state. In many cases this
can be avoided by simply upgrading to the latest TCP/IP patches
supplied by the vendor. In cases where the vendor has never
released patches (i.e., SunOS4 -- although folks with
- a source license can patch it themselves) we have decided to
+ a source license can patch it themselves), we have decided to
disable this feature.
There are two ways of accomplishing this. One is the socket +
There are two ways to accomplish this. One is the socket
option SO_LINGER
. But as fate would have it, this
has never been implemented properly in most TCP/IP stacks. Even
on those stacks with a proper implementation (i.e.,
- Linux 2.0.31) this method proves to be more expensive (cputime)
+ Linux 2.0.31), this method proves to be more expensive (cputime)
than the next solution.
For the most part, Apache implements this in a function
@@ -802,10 +802,10 @@ DocumentRoot "/www/htdocs"
but it is required for a reliable implementation. As HTTP/1.1
becomes more prevalent, and all connections are persistent,
this expense will be amortized over more requests. If you want
- to play with fire and disable this feature you can define
+ to play with fire and disable this feature, you can define
NO_LINGCLOSE
, but this is not recommended at all.
In particular, as HTTP/1.1 pipelined persistent connections
- come into use lingering_close
is an absolute
+ come into use, lingering_close
is an absolute
necessity (and
pipelined connections are faster, so you want to support
@@ -824,7 +824,7 @@ DocumentRoot "/www/htdocs"
for, it typically is implemented using shared memory. The rest
default to using an on-disk file. The on-disk file is not only
slow, but it is unreliable (and less featured). Peruse the
- src/main/conf.h
file for your architecture and
+ src/main/conf.h
file for your architecture, and
look for either USE_MMAP_SCOREBOARD
or
USE_SHMGET_SCOREBOARD
. Defining one of those two
(as well as their companions HAVE_MMAP
and
@@ -832,11 +832,11 @@ DocumentRoot "/www/htdocs"
shared memory code. If your system has another type of shared
memory, edit the file src/main/http_main.c
and add
the hooks necessary to use it in Apache. (Send us back a patch
- too please.)
If you have no intention of using dynamically loaded modules
(you probably don't if you're reading this and tuning your
- server for every last ounce of performance) then you should add
+ server for every last ounce of performance), then you should add
-DDYNAMIC_MODULE_LIMIT=0
when building your
server. This will save RAM that's allocated only for supporting
dynamically loaded modules.
accept(2)
serialization. On this
particular platform, the worker MPM uses an unserialized accept by
- default unless it is listening on multiple ports./65: lwp_park(0x00000000, 0) = 0 -- 2.40.0