performance / tuning tips. to the point.                
About Us | Site Map | Privacy
Disclaimer | Feedback
About RSS Feed
Add to My Yahoo!
Google Reader or Homepage
del.icio.us performancewiki.com Latest Items


© 2006-2007 PerformanceWiki.com
All Rights Reserved.







Apache Web Server Tunings For High Performance



1.3.2x  2.x

1.3.2x

Apache version 1.3.2x has more tunable parameters on UNIX than on Windows.  Windows requires a different programming model.  The following parameters are tuned for large SMP systems with 4GB+ RAM and multiple CPUs, and they are meant for running enterprise applications such as those designed for hundreds of thousands of users, with multiple Apache servers in a topology.  Update the parameters in the httpd.conf file.

Tuning Parameter

Unix value

Windows value

Description

MaxClients (UNIX)
ThreadsPerChild (Windows)

1000

800

Set this value to the number of concurrent users expected.  Monitor your system during normal workload to see if this value needs to be changed.  Use lower for simple but CPU intensive applications, and higher for more complex, database-intensive applications with more wait time.

KeepAlive

NA

on

Enables HTTP persistent connections.  Used with MaxKeepAliveRequests.

KeepAliveTimeout (seconds)

10

15

Set this parameter similar to the average think time for your workload.  Higher Keep-Alive Timeout may increase contention for HTTP server processes.  If you see “running out of HTTP processes” in the http error log, you may want to decrease this value.

MaxKeepAliveRequests

0

0

This allows an unlimited number of requests on a single TCP connection.

MaxRequestsPerChild

0

0

Do not force a server to exit after it has served certain number of requests.  If your version of Apache and Apache library has no known memory leaks, set this to 0.  But if you wish to force the server to exit and be re-created, set this to a relatively high number, e.g., 25000.

StartServers

10

NA

This makes a pool of servers ready on startup.  Specify this number to match the MaxSpareServers parameter.

MaxSpareServers

10

NA

This sets the desired maximum number of idle child server processes that are ready to take of if the request-taking child dies.  The parent process will kill off the excess processes if the number is more than MaxSpareServers.

 

 

 

 

 

Additionally, from the Apache Project web site, http://httpd.apache.org/docs/1.3/misc/perf-tuning.html#runtime, there are other httpd.conf setting worth noting, for example, do not allow hostname lookups:

Note that it's possible to scope the directives, such as within a <Location /server-status> section. In this case the DNS lookups are only performed on requests matching the criteria. Here's an example which disables lookups except for .html and .cgi files: 

HostnameLookups off
<Files ~ "\.(html|cgi)$">
HostnameLookups on
</Files>

2.x

Compared to Apache 1.3, release 2.0 contains many additional optimizations to increase throughput and scalability (e.g., MaxRequestsPerChild by default is already set to 0 as above for v1.3). Most of these improvements are enabled by default. However, there are compile-time and run-time configuration choices that can significantly affect performance. This document describes the options that a server administrator can configure to tune the performance of an Apache 2.0 installation.  Some excerpt:

FollowSymLinks and SymLinksIfOwnerMatch

Wherever in your URL-space you do not have an 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 />
    Options SymLinksIfOwnerMatch
</Directory>

and a request is made for the URI /index.html. Then Apache will perform lstat(2) on /www, /www/htdocs, and /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:

DocumentRoot /www/htdocs
<Directory />
    Options FollowSymLinks
</Directory>

<Directory /www/htdocs>
    Options -FollowSymLinks +SymLinksIfOwnerMatch
</Directory>

This at least avoids the extra checks for the DocumentRoot path. Note that you'll need to add similar sections if you have any Alias or RewriteRule paths outside of your document root. For highest performance, and no symlink protection, set FollowSymLinks everywhere, and never set SymLinksIfOwnerMatch.

So much more at: http://httpd.apache.org/docs/2.0/misc/perf-tuning.html.