In order to get the best out of Apache HTTP Server, there are several things that you can do to improve the performance of your server environment. However, optimization may not be necessary if your site only processes a few hundred or even a few thousand requests a day. In that case, it’s likely that the default configurations are sufficient.
Here are a few Apache optimizations that you can, and probably should, do:
- Disable or remove unused modules. Apache comes with many, many modules. Be sure to carefully review the ones that are enabled to ensure you are only activating and using the ones that you need. By not loading unneeded modules, you will save memory on your server.
- Use caching. In order to reduce the overhead on your server and minimize the processor requests, activate and use caching technology within Apache. Use disk caching (mod_disk_cache) over memory caching (mod_mem_cache), especially if you are limited in the amount of RAM available to your server. And, if possible, externalize your disk cache to a different (hopefully fast) external drive. And if you use caching, be sure to set up the appropriate expire times; otherwise, you defeat the purpose of caching. However, if you have frequently used data and sessions, memcaching is optimal and can reduce the load on database queries.
- Use compression. Wherever possible, try to compress the content prior to sending it out. Using gzip, for example, will reduce the size of the files being transmitted. These files can then be uncompressed, within the browser, when they are received by the end user. Look at mod_gzip or mod_deflate for these options.
- Turn off host name lookups. In previous versions of Apache, hostname lookups defaulted to “on,” which added latency to requests. That’s because every time a host name was encountered, a DNS lookup was required. Although this setting in Apache 1.3 and later defaults to “off,” be sure to check.
- 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.