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 MaxRequestWorkers
setting so that your server
- does not spawn so many children it starts swapping. This procedure
+ should, control the MaxRequestWorkers
setting, so that your server
+ does not spawn so many children that it starts swapping. The procedure
for doing this is simple: determine the size of your average Apache
process, by looking at your process list via a tool such as
top
, and divide this into your total available memory,
@@ -82,7 +82,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:
DocumentRoot "/www/htdocs" <Directory "/"> @@ -173,7 +173,7 @@/www/htdocs/index.html
. The results of theselstats
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:DocumentRoot "/www/htdocs" <Directory "/"> @@ -187,7 +187,7 @@This at least avoids the extra checks for the
DocumentRoot
path. - Note that you'll need to add similar sections if you + Note that you'll need to add similar sections, if you have anyAlias
orRewriteRule
paths outside of your document root. For highest performance, @@ -201,7 +201,7 @@Wherever in your URL-space you allow overrides (typically -
@@ -225,7 +225,7 @@ -.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. @@ -247,7 +247,7 @@ 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 theOptions MultiViews
directive to accomplish the negotiation. See the Content Negotiation @@ -262,7 +262,7 @@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. @@ -298,7 +298,7 @@
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 @@ -337,14 +337,14 @@
MinSpareServers
setting. So a server being accessed by 100 simultaneous clients, using the defaultStartServers
of5
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 @@ -358,7 +358,7 @@ unnecessary to twiddle the
MinSpareServers
,MaxSpareServers
andStartServers
knobs. When more than 4 children are spawned per second, a message will be emitted to theErrorLog
. If you - see a lot of these errors then consider tuning these settings. + see a lot of these errors, then consider tuning these settings. Use themod_status
output as a guide.Related to process creation is process death induced by the @@ -528,7 +528,7 @@ -
accept Serialization - multiple sockets
+accept Serialization - Multiple Sockets
@@ -542,7 +542,7 @@This discusses a shortcoming in the Unix socket API. Suppose your web server uses multiple
+ 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).Listen
statements to listen on either multiple ports or multiple addresses. In order to test each socket - to see if a connection is ready Apache uses + to see if a connection is ready, Apache usesselect(2)
.select(2)
indicates that a socket has zero or at least one connection waiting on it. Apache's model includes multiple children, and @@ -579,12 +579,12 @@ time, and so multiple children will block atselect
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 toaccept
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 inaccept
. 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 @@ -602,9 +602,9 @@ accomplishing nothing. Meanwhile none of those children are servicing requests that occurred on other sockets until they get back up to theselect
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 @@ -656,7 +656,7 @@
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 @@ -669,16 +669,16 @@ -
accept Serialization - single socket
+accept Serialization - Single Socket
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
@@ -700,8 +700,8 @@ single-socket showed an extra 100ms latency on each request. This latency is probably a wash on long haul lines, and only an issue on LANs. If you want to override the single socket - serialization you can define -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 inaccept
when a single connection arrives. One of @@ -686,7 +686,7 @@ 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. @@ -713,27 +713,27 @@As discussed in draft-ietf-http-connection-00.txt section 8, in order for an HTTP server to reliably implement the - protocol it needs to shutdown 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 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 theFIN_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 @@ -770,10 +770,10 @@ 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
@@ -791,7 +791,7 @@ 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 -NO_LINGCLOSE
, but this is not recommended at all. In particular, as HTTP/1.1 pipelined persistent connections - come into uselingering_close
is an absolute + come into use,lingering_close
is an absolute necessity (and pipelined connections are faster, so you want to support them).src/main/conf.h
file for your architecture and +src/main/conf.h
file for your architecture, and look for eitherUSE_MMAP_SCOREBOARD
orUSE_SHMGET_SCOREBOARD
. Defining one of those two (as well as their companionsHAVE_MMAP
and @@ -799,11 +799,11 @@ shared memory code. If your system has another type of shared memory, edit the filesrc/main/http_main.c
and add the hooks necessary to use it in Apache. (Send us back a patch - too please.) + too, please.)Historical note: The Linux port of Apache didn't start to use shared memory until version 1.2 of Apache. This oversight - resulted in really poor and unreliable behaviour of earlier + resulted in really poor and unreliable behavior of earlier versions of Apache on Linux.@@ -814,7 +814,7 @@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
@@ -854,7 +854,7 @@-DDYNAMIC_MODULE_LIMIT=0
when building your server. This will save RAM that's allocated only for supporting dynamically loaded modules.Note the lack of+ default, unless it is listening on multiple ports.accept(2)
serialization. On this particular platform, the worker MPM uses an unserialized accept by - default unless it is listening on multiple ports.diff --git a/docs/manual/misc/perf-tuning.xml.fr b/docs/manual/misc/perf-tuning.xml.fr index 00b64541d2..578a404b01 100644 --- a/docs/manual/misc/perf-tuning.xml.fr +++ b/docs/manual/misc/perf-tuning.xml.fr @@ -1,7 +1,7 @@ - + diff --git a/docs/manual/misc/perf-tuning.xml.ko b/docs/manual/misc/perf-tuning.xml.ko index 4f4b05fb9a..559f3d6689 100644 --- a/docs/manual/misc/perf-tuning.xml.ko +++ b/docs/manual/misc/perf-tuning.xml.ko @@ -1,7 +1,7 @@ - + +/65: lwp_park(0x00000000, 0) = 0 /67: lwp_unpark(65, 1) = 0