Dec 14, 2011

Apache performance tuning: dynamic modules (I)

Apache is a cross-platform, modular and open source web server, widely used around the world for its quality, robustness and stability. But like most of the applications, it is installed with a default configuration which is not the most adequate. And I am going to say more: I have never seen an Apache installation where the administrator has set it up correctly later.

During several articles, you are going to learn how to properly optimize Apache, in order to achieve the best performance. The tests will be carried out on CentOS 6.2 (32 bits) with Apache 2.2.15. I am going to break up this first article relative to dynamic modules in two separate parts.

Apache has got two main operating modes, also known as multi-processing modules (MPMs):

  • Prefork: an unique Apache process (httpd) launchs child processes which take care of listening for potential connections and serving them. Apache keeps several idle processes ready to attend incoming requests. Thereby, a client does not need to wait for new children are forked. Another advantage of this operation mode is that if there is a problem in any process, this will not affect other processes (each child is independent of the rest). 

  • Worker: as in the previous case, an only control process creates several child processes, and in turn, each child process handles a listener thread which passes the inbound connections to other server threads managed as well by the same child process. This mode is faster and more scalable, but in contrast, it is more fault tolerant (several threads share the same memory area, and if there is any problem in the parent, it will involve the rest).

You can install Apache either by compiling it from its source code or by getting directly the binary file from a repository. I for one prefer this second option, because in this way, any kind of update (security or bugfix) will be able to be applied without compiling it again.

A typical installation of Apache via yum comes with the following pre-compiled modules. As you may appreciate, prefork will be the default operating mode (you can change this by modifying the /etc/sysconfig/httpd file).

[root@centos ~]# httpd -l
Compiled in modules:

It is basic to know the funcionality of each module so as to figure out if it can be left out. Then we are going to put forward what modules can be ruled out in the most of the cases. Also point out that all directives showed below, are included into the Apache configuration file (httpd.conf). In many cases, the related modules will be also disabled, aside from the principal one.


Allows the execution of CGI scripts based on the MIME content type and the request method.

# LoadModule actions_module modules/


Limits access to certain users by using HTTP Basic Authentication. I usually disable its dependencies.

LoadModule auth_basic_module modules/
# LoadModule authn_file_module modules/
# LoadModule authn_alias_module modules/
# LoadModule authn_anon_module modules/
# LoadModule authn_dbm_module modules/
# LoadModule authn_default_module modules/
# LoadModule authnz_ldap_module modules/
# LoadModule authn_dbd_module modules/


Limits access to certain users by using MD5 Digest Authentication.

# LoadModule auth_digest_module modules/


Limits access to certain groups based on different origins (DBM or plaintext files, hostname or IP address, etc.). I get used to remove all less mod_authz_host.

LoadModule authz_host_module modules/
# LoadModule authz_user_module modules/
# LoadModule authz_owner_module modules/
# LoadModule authz_groupfile_module modules/
# LoadModule authz_dbm_module modules/
# LoadModule authz_default_module modules/


Manages the content cache.

# LoadModule cache_module modules/
# LoadModule disk_cache_module modules/


Allows the execution of CGI scripts.

# LoadModule cgi_module modules/


Implements the WebDAV (Web-based Distributed Authoring and Versioning) funcionality.

# LoadModule dav_module modules/
# LoadModule dav_fs_module modules/


Controls the internal environment variables which are sent out to CGI scripts and SSI pages.

# LoadModule env_module modules/

No comments:

Post a Comment