Improving Apache performance

Remove modules
Apache include many modules that are enabled, and you may not be needing all of them, disable the ones you do not need. (By default in CentOS when you install Apache, over 50 modules are loaded.) This will help speed up Apache. The modules that are loading are listed in /etc/httpd/conf/httpd.conf and the line begins with the word LoadModule, as in:

LoadModule auth_basic_module modules/mod_auth_basic.so

For instance if you don’t use LDAP to authenticate with Apache, you can disable the authnz_ldap_module module.
If you are unsure about disabling an Apache module whose name is perhaps not self explanatory, you can take a look here http://httpd.apache.org/docs/2.2/mod/ for a more detailed description.

DNS tunning
Each DNS lookup takes up time, so make sure that Apache is not doing hostname lookups, you can enable this feature with the following directive ‘HostnameLookups Off’. This is normally off by default.

Don’t use htaccess if there is no need to
Use ‘AllowOverride None’, since allowing override will force Apache to look for .htaccess file, which you may not be using. This will speed up Apache, since it’s one less thing that Apache has to do before serving content.

Avoid content negotiation
When you access the root directory of a web server, Apache usually looks for an index file which is basically the ‘home-page’ of a web server. This file can have various names such as index, index.html, etc. You can specify the exact filename so that Apache does not have to look for different files. So replace ‘DirectoryIndex index’ with ‘DirectoryIndex index.cgi index.pl index.shtml index.html’

How do you improve Apache’s performance? Share your comments in the blog.

Reference
http://httpd.apache.org/docs/current/misc/perf-tuning.html

2 thoughts on “Improving Apache performance

  1. can you please list which module not be use for apache perdormance tunning
    Mohammad Kazim Hanifi
    Linux Admin.

    • Hi,
      The modules you can remove depends on whether you are using that module’s functionality or not. Some modules that you can perhaps try commenting out are listed below.


      LoadModule auth_basic_module modules/mod_auth_basic.so
      LoadModule auth_digest_module modules/mod_auth_digest.so
      LoadModule authn_file_module modules/mod_authn_file.so
      LoadModule authn_alias_module modules/mod_authn_alias.so
      LoadModule authn_anon_module modules/mod_authn_anon.so
      LoadModule authn_dbm_module modules/mod_authn_dbm.so
      LoadModule authn_default_module modules/mod_authn_default.so
      LoadModule authz_host_module modules/mod_authz_host.so
      LoadModule authz_user_module modules/mod_authz_user.so
      LoadModule authz_owner_module modules/mod_authz_owner.so
      LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
      LoadModule authz_dbm_module modules/mod_authz_dbm.so
      LoadModule authz_default_module modules/mod_authz_default.so
      LoadModule ldap_module modules/mod_ldap.so
      LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
      LoadModule logio_module modules/mod_logio.so
      LoadModule ext_filter_module modules/mod_ext_filter.so
      LoadModule mime_magic_module modules/mod_mime_magic.so
      LoadModule usertrack_module modules/mod_usertrack.so
      LoadModule setenvif_module modules/mod_setenvif.so
      LoadModule mime_module modules/mod_mime.so
      LoadModule dav_module modules/mod_dav.so
      LoadModule status_module modules/mod_status.so
      LoadModule autoindex_module modules/mod_autoindex.so
      LoadModule dav_fs_module modules/mod_dav_fs.so
      LoadModule dir_module modules/mod_dir.so
      LoadModule actions_module modules/mod_actions.so
      LoadModule speling_module modules/mod_speling.so
      LoadModule userdir_module modules/mod_userdir.so
      LoadModule substitute_module modules/mod_substitute.so
      LoadModule rewrite_module modules/mod_rewrite.so
      LoadModule proxy_module modules/mod_proxy.so
      LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
      LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
      LoadModule proxy_http_module modules/mod_proxy_http.so
      LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
      LoadModule proxy_connect_module modules/mod_proxy_connect.so

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s