Text of httpd.apache.org › docs › trunk › misc › perf-tuning.html as Styx crawled it on Nov 18, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

Apache Performance Tuning - Apache HTTP Server Version 2.5

Modules | Directives | FAQ | Glossary | Sitemap | Report a bug Apache HTTP Server Version 2.5 Apache > HTTP Server > Documentation > Version 2.5 > Miscellaneous Documentation Apache Performance Tuning Available Languages: en | fr | ko | tr Warning This document is partially out of date and might be inaccurate. Apache 2.4 is a general-purpose webserver, designed to provide a balance of flexibility, portability, and performance.

Although it has not been designed specifically to set benchmark records, Apache 2.4 is capable of high performance in many real-world situations. This document describes the options that a server administrator can configure to tune the performance of an Apache 2.4 installation. Some of these configuration options enable the httpd to better take advantage of the capabilities of the hardware and OS, while others allow the administrator to trade functionality for speed.

Hardware and Operating System Issues Run-Time Configuration Issues Compile-Time Configuration Issues Appendix: Detailed Analysis of a Trace Hardware and Operating System Issues ¶ The single biggest hardware issue affecting webserver performance is RAM. A webserver should never ever have to swap, as swapping increases the latency of each request beyond a point that users consider "fast enough". This causes users to hit stop and reload, further increasing the load.

You can, and 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, leaving some room for other processes. Beyond that the rest is mundane: get a fast enough CPU, a fast enough network card, and fast enough disks, where "fast enough" is something that needs to be determined by experimentation.

Operating system choice is largely a matter of local concerns. But some guidelines that have proven generally useful are: 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. If your OS supports a sendfile(2) system call, make sure you install the release and/or patches needed to enable it. (With Linux, for example, this means using Linux 2.4 or later.

For early releases of Solaris 8, you may need to apply a patch.) On systems where it is available, sendfile enables Apache to deliver static content faster and with lower CPU utilization. Run-Time Configuration Issues ¶ Related Modules Related Directives mod_dir mpm_common mod_status AllowOverride DirectoryIndex HostnameLookups EnableMMAP EnableSendfile KeepAliveTimeout MaxSpareServers MinSpareServers Options StartServers HostnameLookups and other DNS considerations Prior to Apache 1.3, HostnameLookups defaulted to On . causing an extra latency penalty for every request due to a DNS lookup to complete before the request was finished.

In Apache 2.4 this setting defaults to Off . If you need to have addresses in your log files resolved to hostnames, please consider post-processing rather than forcing Apache to do it in the first place. It is recommended that you do this sort of post-processing of your log files on some machine other than the production web server machine, in order that this activity not adversely affect server performance. If you use any Allow from domain or Deny from domain directives (i.e., using a hostname, or a domain name, rather than an IP address) then you will pay for two DNS lookups (a reverse, followed by a forward lookup to make sure that the reverse is not being spoofed).

For best performance, whenever it is possible, use IP addresses rather than domain names. Warning: Please use the Require directive with Apache 2.4; more info in the related upgrading guide . 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: <Files ~ "\.(html|cgi)$"> HostnameLookups on </Files> But even still, if you just need DNS names in some CGIs you could consider doing the gethostbyname call in the specific CGIs that need it.

FollowSymLinks and SymLinksIfOwnerMatch Wherever in your URL-space you do not have an Options FollowSymLinks , or you do have an Options SymLinksIfOwnerMatch , Apache will need 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 . AllowOverride Wherever in your URL-space you allow overrides (typically .htaccess files), Apache will attempt to open .htaccess for each filename component. For example, DocumentRoot "/www/htdocs" <Directory "/"> AllowOverride all </Directory> and a request is made for the URI /index.html . Then Apache will attempt to open /.htaccess , /www/.htaccess , and /www/htdocs/.htaccess .

The solutions are similar to the previous case of Options FollowSymLinks . For highest performance use AllowOverride None everywhere in your filesystem. Negotiation 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. Instead of using a wildcard such as: DirectoryIndex index Use a complete list of options: DirectoryIndex index.cgi index.pl index.shtml index.html where you list the most common choice first.

Also note that explicitly creating a type-map file provides better performance than using MultiViews , as the necessary information can be determined by reading this single file, rather than having to scan the directory for files. 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 documentation for a full discussion of the methods of negotiation, and instructions for creating type-map files.

Memory-mapping 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 some form of mmap(2) . On some platforms, this memory-mapping improves performance. However, there are cases where memory-mapping can hurt the performance or even the stability of the httpd: On some operating systems, mmap does not scale as well as read(2) when the number of CPUs increases.

On multiprocessor Solaris servers, for example, Apache 2.x sometimes delivers server-parsed files faster when mmap is disabled. If you memory-map a file located on an NFS-mounted filesystem and a process on another NFS client machine deletes or truncates the file, your process may get a bus error the next time it tries to access the mapped file content. For installations where either of these factors applies, you should

The rest of this page is on the live site.