Apache Performance Tuning CentOS / Redhat

14 August 2017

Apache, Tuning, Optimization, Performance, IGP Solutions

How to optimize Apache to ensure speed, reliability and maximize the  performance.

Apache is the most widely used open source web server software. It is fast, reliable, and secure. It can be highly customized to meet the needs of many different environments by using extensions and modules.

Infogrid Pacific uses Apache as the web server for our very large and ever expanding digital content production and delivery solutions.

Lack of tuning can result in Apache becoming a memory hog. It's now just the tools you use, but how you use them that matters.

This post explains how to tune or configure Apache on CentOS-6 / Redhat-6 to get maximum performance specifically for IGP Applications and any general use.

Before you start "messing" with your Apache install, please note the following:

  • Have “root” access. In order to fully configure the following items, you will need to have root or equivalent administrative user access to your server environment, most likely through SSH. Otherwise, you won’t be able to make the required changes.
  • Backup. Before you make any changes, be sure that you have a full backup of your server or of the files you will be modifying.
  • Test. If you have access to a clone of the server, then do all of the testing on the clone. This is where a cloud hosting environment can be helpful.
  • Document. As you go through your optimizations, be sure to document all of the changes you make. You might want to do this in an external document. That way, if you don’t have access to your server, you will know what you were doing, and when. Within the files, comment about any changes or modifications that you make.
  • Upgrade. Be sure that you upgrade to the latest stable release and patch level that your operating system supports; there are always performance (and security) improvements in these later versions.

1. Remove Unused Modules

Save memory by not loading modules that you do not need, including but not limited to mod_php, mod_ruby, mod_perl, etc.

2. Turn HostnameLookups Off

Stop doing expensive DNS lookups.  You will rarely ever need them and when you do, you can look them up after the fact.

3. Do Not set KeepAliveTimeout too high

If you have more requests than apache children, this setting can starve your pool of available clients.

4. Allow symlinks

Example: Options +FollowSymLinks -SymLinksIfOwnerMatch.  Otherwise, apache will make a separate call on each filename to ensure it is not a symlink.

5. Set ExtendedStatus Off 

Although very useful, the ExtendedStatus will produce several system calls for each request to gather statistics.  Better to utilize for a set time period in order to benchmark, then turn it off.

6. Avoid Wildcards in DirectoryIndex

Use a specific DirectoryIndex, i.e. index.html or index.php, not inde

7. Increase Swappiness

Particularly on single site hosts this will increase performance.  On linux systems increase /proc/sys/vm/swappiness to at least 60 if not greater. This will try to load as many files as possible into the memory cache for faster access.

8. Increase Write Buffer Size

Increase your write buffer size for tcp/ip buffers.  On linux systems increase /proc/sys/net/core/wmem_max and /proc/sys/net/core/wmem_default. If your pages fit within this buffer, apache will complete a process in one call to the tcp/ip buffer.

9. Increase Max Open Files

If you are handling high loads increase the number of allowed open files.  On linux, increase /proc/sys/fs/file-max and run ulimit -H -n 4096.

10. Disable Apache Web Server Signature

Whenever Apache web server returns error pages (e.g., 404 not found, 403 access forbidden pages), it shows the web server signature (e.g., Apache version number and operating system info) at the bottom of the pages. Also, when Apache web server serves any PHP pages, it reveals the PHP version info.

11. Disable directory browsing in apache/httpd?

Disable building of directory index in apache/httpd? In other words, how to prevent users from seeing the contents of published directories

12. Upgrade RAM and storage

While this is not specifically an Apache modification, this optimization is something that will improve the performance of any server. Giving more RAM to Apache means that the number of simultaneous requests can be increased and run faster. Upgrading the hard drive to one that supports faster I/O can also help, especially for database requests and disk cache-based transactions.

13. ExtendedStatus

If mod_status is included, make sure that directive 'ExtendedStatus' is set to 'Off'. Otherwise, Apache will issue several extra time-related system calls on every request made.

ExtendedStatus Off

14. Timeout

Lower the amount of time the server will wait before failing a request.

Timeout 45

15. SymLinks

Make sure 'Options +FollowSymLinks -SymLinksIfOwnerMatch' is set for all directories. Otherwise, Apache will issue an extra system call per filename component to substantiate that the filename is NOT a symlink; and more system calls to match an owner.

<Directory />

      Options FollowSymLinks


16.  Do Not set KeepAliveTimeout too high

If you have more requests than apache children, this setting can starve your pool of available clients.

17. Disable .htaccess

Example:   AllowOverride None  This will prevent apache from having to check for a .htaccess file on each request.

18. Tune  using mpm prefork module

There could be many reasons why your website performance is poor. It may be that Apache is just not coping with the load. Below you’ll find a ready to consume configuration to make Apache performance better using the Apache MPM prefork module.

As per server configuration should set prefork MPM

# StartServers:    number of server processes to start

# MinSpareServers:    minimum number of server processes
which are kept spare

# MaxSpareServers:    maximum number of server processes which are kept spare

# ServerLimit:    maximum value for MaxClients for the lifetime of the server

# MaxClients:    maximum number of server processes allowed to start

# MaxRequestsPerChild:     maximum number of requests a server process serves


Infogrid Pacific runs dozens of Apache servers for both our own internal and external requirements and for customers around the world. The servers are deployed in the Cloud, on remote server farms and locally.

Our web applications are high volume, high throughput solutions with hundreds of users making data changes and commitments every minute. That is the nature of digital content ownership. Authors, editors and production staff make constant changes.

IGP:Digital Publisher is a very high database read/write application while delivery solutions such as IGP:Distribution Manager and AZARDI:Content Fulfilment are very high read applications. Tuning is essential for maximum performance no matter the content transactions.

We hope these tips help someone out there get more from their Apache installations, and we would love to hear any suggestions on other performance tips.

Posted by Vishal Sapkal - IGP System Administration Manager

comments powered by Disqus