Tips To Boost the Performance of Your Apache Web Server
Tips To Boost the Performance of Your Apache Web Server
- April 27, 2016
- Posted by: MMontaser
- Category: Uncategorized web hosting

Apache continues to be the most widely used web server among sites and Internet-facing computers.Additionally, Apache keeps experiencing the largest growth among the top web servers, followed by Nginx and IIS. Thus, if you are a system administrator in charge of managing Apache installations, you need to know how to make sure your web server performs at the best of its capacity according to your (or you client’s) needs.In this article we will discuss a few tips that will help you ensure that Apache will run smoothly and be able to handle the number of requests you are expecting from remote clients.However, please keep in mind that Apache was not designed with the objective of setting benchmark records – but, even so, it is still capable of providing high performance in almost any usage case you can possibly think of.
TIP #1: Always keep Apache updated to its latest version
It goes without saying that having the latest version of Apache installed is probably one of the first things you need to consider. As of November 19, 2015, the latest version of Apache available in the CentOS 7 repositories is 2.4.6, whereas in Debian’s is 2.4.10.However, there may be a recent improvement or a bug fix that has been added to a newly-released stable version, which is then made available to download and install from source.
In any event, you can check your currently installed version as follows:
# httpd -v
As a rule of thumb, stick with the update method provided by the package manager of your chosen distribution (#yum update httpd)
for CentOS .
TIP #2: If you are using a Kernel older than 2.4, consider upgrading now
Why? Kernel versions 2.4 and above have the send file kernel system call enabled by default. That, in turn, facilitates high performance network file transfers (which are desired in the context of web server-client communications) and enables Apache to deliver static content faster and with lower CPU utilization by performing simultaneous read and send operations.
You can view your currently installed kernel with:
# uname -r
and compare it to the latest stable kernel in www.kernel.org
TIP #3: Choose the Multi-Processing Module (MPM) that works best for your case
In practice, MPMs extend the modular functionality of Apache by allowing you to decide how to configure the web server to bind to network ports on the machine, accept requests from clients, and use children processes (and threads, alternatively) to handle such requests.
Beginning with version 2.4, Apache offers three different MPMs to choose from, depending on your needs:
- The
prefork
MPM uses multiple child processes without threading. Each process handles one connection at a time without creating separate threads for each. Without going into too much detail, we can say that you will want to use this MPM only when debugging an application that uses, or if your application needs to deal with, non-thread-safe modules like mod_php. - The
worker
MPM uses several threads per child processes, where each thread handles one connection at a time. This is a good choice for high-traffic servers as it allows more concurrent connections to be handled with less RAM than in the previous case. - Finally, the
event
MPM is the default MPM in most Apache installations for versions 2.4 and above. It is similar to the worker MPM in that it also creates multiple threads per child process but with an advantage: it causes KeepAlive or idle connections (while they remain in that state) to be handled by a single thread, thus freeing up memory that can be allocated to other threads. This MPM is not suitable for use with non-thread-safe modules like mod_php, for which a replacement such a PHP-FPM must be used instead.
To check the MPM used by your Apache installation, you can do:
#httpd -V
Note: V Is Acapital letter.
TIP #4: Allocate RAM wisely for Apache
Perhaps the most critical hardware item to be taken into account is the amount of RAM allocated for each Apache process. While you cannot control this directly, you can restrict the number of child processes through the MaxRequestWorkers directive (formerly known as MaxClients in Apache 2.2), which will put limits on the RAM usage by Apache. Again, you can set this value on a per host or per virtual host basis.
To do this, you should take note of the average amount of RAM used by Apache, then multiply it by the number of MaxRequestWorkers, and that is the amount of memory that will be allocated for Apache processes. One thing you never want your web server to do is to begin using swap, as that will significantly decrease its performance. Thus, you should always keep the usage of RAM by Apache within the limits that you can afford and never rely on swap for it.
TIP #5: Know your applications
As a rule of thumb, you should not load any Apache modules that are not strictly needed for your application to work. This will require at least an overall knowledge of the applications running on your server, specially if you are a system administrator and there’s another team in charge of development.
You can list the currently loaded modules with:
# httpd -MSummary
In this article we have reviewed 5 tips that will help you tune the Apache web server and increase its performance.