14 August 2017
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:
Save memory by not loading modules that you do not need, including but not limited to mod_php, mod_ruby, mod_perl, etc.
Stop doing expensive DNS lookups. You will rarely ever need them and when you do, you can look them up after the fact.
If you have more requests than apache children, this setting can starve your pool of available clients.
Example: Options +FollowSymLinks -SymLinksIfOwnerMatch. Otherwise, apache will make a separate call on each filename to ensure it is not a symlink.
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.
Use a specific DirectoryIndex, i.e. index.html or index.php, not inde
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.
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.
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.
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.
Disable building of directory index in apache/httpd? In other words, how to prevent users from seeing the contents of published directories
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.
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
Lower the amount of time the server will wait before failing a request.
Timeout 45
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
</Directory>
If you have more requests than apache children, this setting can starve your pool of available clients.
Example: AllowOverride None This will prevent apache from having to check for a .htaccess file on each request.
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