From cb9e6cd9b4292d06c4a2bcb88f94e3f4244d2fc9 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Igor=20Gali=C4=87?= The Performance Tuning page in the Apache 1.3 documentation says:
+ â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 fill using only a low end Pentium-based
- webserver.â
-
-
+ webserver.â
However, this sentence was written a few years ago, and in the meantime several things have happened. On one hand, web server hardware has become much faster. On the other hand, many sites now @@ -91,7 +90,7 @@
The top tool ships with Linux and FreeBSD. Solaris offers
- `prstat'. It collects a number of statistics for the
+ prstat(1)
. It collects a number of statistics for the
system and for each running process, then displays them
interactively on your terminal. The data displayed is
refreshed every second and varies by platform, but
@@ -179,10 +178,8 @@
top ten CPU gluttons). It is indispensable in determining
the size of a running process, which comes in handy when
determining how many server processes you can run on your
- machine. How to do this is described in '
- sizing MaxClients
-
- '. Top is, however, an interactive tool and running it
+ machine. How to do this is described in sizing MaxClients.
+ Top is, however, an interactive tool and running it
continuously has few if any advantages.
- vmstat 5
-
+ redisplayed at designated intervals. For example,
+ vmstat 5
causes the information to reappear every five seconds.
Vmstat displays the amount of virtual memory in use, how
much memory is swapped in and out each second, the number
@@ -228,9 +222,7 @@
percentages of the CPU.
- The following is vmstat
-
- output of an idle server:
+ The following is vmstat
output of an idle server:
ExtendedStatus On
-
- directive in your httpd.conf
-
- ,the mod_status
-
+ Foundation uses ExtendedStatus On
+ directive in your httpd.conf
,
+ the
- /var/log/messages
-
+ early error messages depends on their design. The
+ /var/log/messages
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.
- The Error Log is configured through the ErrorLog
-
- and LogLevel
-
+ The Error Log is configured through the ErrorLog
-
+ process spawns, etc. The
- The LogLevel
-
+ The
- - Level - - +Level |
- - Description - - +Description |
- emerg - +emerg |
- Emergencies - system is unusable. - +Emergencies - system is unusable. |
- alert - +alert |
- Action must be taken immediately. - +Action must be taken immediately. |
- crit - +crit |
- Critical Conditions. - +Critical Conditions. |
- error - +error |
- Error conditions. - +Error conditions. |
- warn - +warn |
- Warning conditions. - +Warning conditions. |
- notice - +notice |
- Normal but significant condition. - +Normal but significant condition. |
- info - +info |
- Informational. - +Informational. |
- debug - +debug |
- Debug-level messages - +Debug-level messages |
The default log level is warn. A production server should
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 LogLevel
-
+ Starting with 2.3.8
- This puts all of the server in debug mode, except for
- mod_ssl
-
- ,which tends to be very noisy.
+ This puts all of the server in debug mode, except for
+
TransferLog
-
- or CustomLog
-
+ The various logging format features are documented in the
+ manual. This file exists by default for the main server and can be
+ configured per virtual host by using the The access logs can be analyzed with any of several free and @@ -575,121 +527,90 @@
- - Field - - +Field |
- - Content - - +Content |
- - Explanation - - +Explanation |
- Client IP - +Client IP |
- 195.54.228.42 - +195.54.228.42 |
- IP address where the request originated - +IP address where the request originated |
- RFC 1413 ident - +RFC 1413 ident |
- - - +- |
- Remote user identity as reported by their - identd - +Remote user identity as reported by their identd |
- username - +username |
- - - +- |
- Remote username as authenticated by Apache - +Remote username as authenticated by Apache |
- timestamp - +timestamp |
- [24/Mar/2007:23:05:11 -0400] - +[24/Mar/2007:23:05:11 -0400] |
- Date and time of request - +Date and time of request |
- Request - +Request |
- "GET /sander/feed/ HTTP/1.1" - +"GET /sander/feed/ HTTP/1.1" |
- Request line - +Request line |
- Status Code - +Status Code |
- 200 - +200 |
- Response code - +Response code |
- Content Bytes - +Content Bytes |
- 9747 - +9747 |
- Bytes transferred w/o headers - +Bytes transferred w/o headers |
- A second approach is to use piped logs. From the
- CustomLog
-
- ,TransferLog
-
- or ErrorLog
-
+ A second approach is to use piped logs. From the
+ |
-
- ). For instance:
+ a pipe character (|
). For instance:
- Do not run a production server with your error
- LogLevel
-
- set to debug. This log level causes a vast amount of
+ Do not run a production server with your error support/split-logfile
.
- You can use the BufferedLogs
-
+ You can use the MaxClients
-
+ quickly. The formula for determining
/etc/login.conf
these resources can be limited or extended system wide,
- analogously to limits.conf
-
- .'Soft' limits can be specified with -cur
-
- and 'hard' limits with -max
-
- .
+ analogously to limits.conf
.
+ 'Soft' limits can be specified with -cur
+ and 'hard' limits with -max
.
Solaris has a similar mechanism for manipulating limit
- values at boot time: In /etc/system
-
+ values at boot time: In /etc/system
you can set kernel tunables valid for the entire system at
boot time. These are the same tunables that can be set with
- the mdb
-
+ the mdb
kernel debugger during run time. The soft and hard limit
corresponding to ulimit -u can be set via:
Solaris calculates the maximum number of allowed processes
- per user (maxuprc
-
- )based on the total amount available memory on the system (
- maxusers
-
- ). You can review the numbers with
+ per user (maxuprc
) based on the total amount
+ available memory on the system (maxusers
).
+ You can review the numbers with
On Red Hat Linux, the chkconfig tool will help you do this
- from the command line. On Solaris systems svcs
-
- and svcadm
-
+ from the command line. On Solaris systems svcs
+ and svcadm
will show which services are enabled and disable them
respectively.
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
- LoadModule
-
- directive.
+ distributions, have their modules enabled through the
+
Unused modules may be culled: if you don't rely on
their functionality and configuration directives, you can
- turn them off by commenting out the corresponding
- 'we should provide a more useful example here.
- One showing how to make Wordpress or Drupal suck less.
-
- '
- 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
@@ -1417,8 +1313,7 @@
To run blosxom for static page generation, edit the CGI
script according to the documentation. Set the $static dir
- variable to the
- LoadModule
-
+ turn them off by commenting out the corresponding
+ DocumentRoot
-
+ variable to the
- --enable-rewrite[=shared]
-
+ the server by passing the option --enable-rewrite[=shared]
to the configure command. Many binary distributions of
- Apache come with mod_rewrite included. The following is an
+ Apache come with
- The RewriteCond
-
- and RewriteRule
-
+ The
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 Etag:
-
- ,Last-Modified:
-
- or Expires:
-
- ,mod_cache can not make the right decision on whether to cache
+ headers. Without headers like Etag:
,
+ Last-Modified:
or Expires:
,
+ --enable-cache[=shared]
-
+ option --enable-cache[=shared]
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 mod_cache already included.
+ it may have
- 'Is this still the case? Maybe we should give - a better example here too. - -
+
The Apache Software Foundation Wiki is served by MoinMoin.
MoinMoin is written in Python and runs as a CGI. To date, any
@@ -1563,9 +1446,7 @@
the corresponding Python modules were patched to send the
proper HTTP response headers. After this modification, the
cache in front of the Wiki was enabled with the following
- configuration snippet in httpd.conf
-
- :
+ configuration snippet in httpd.conf
:
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 CacheMaxExpire
-
- directive). If no Expires:
-
- header is present in the response, mod_cache will compute
- an expiration period from the Last-Modified:
-
- header. The computation using CacheLastModifiedFactor
-
+ more than six hours (the Expires:
+ header is present in the response, Last-Modified:
+ header. The computation using
- Do note that it can pay off to disable
-
- the ETag:
-
+ Do note that it can pay off to disable
+ the ETag:
header: For files smaller than 1k the server has to
- calculate the checksum (usually MD5) and then send out a
- 304 Not Modified
-
- response, which will take waste some CPU and still saturate
+ calculate the checksum (usually MD5) and then send out a
+ 304 Not Modified
+ response, which will use up some CPU and still saturate
the same amount of network resources for the transfer (one
TCP packet). For resources larger than 1k it might prove
CPU expensive to calculate the header for each request.
@@ -1617,8 +1491,7 @@
- This will disable the generation of the ETag:
-
+ This will disable the generation of the ETag:
header for most static resources. The server does not
calculate these headers for dynamic resources.
Armed with the knowledge of how to tune a sytem to deliver the - desired the performance, we will soon discover that one - + desired the performance, we will soon discover that one system might prove a bottleneck. How to make a system fit for growth, or how to put a number of systems into tune will be - discussed in - PerformanceScalingOut - - . + discussed in PerformanceScalingOut.