Linux Network

Apache MaxClients parameter tuning for web server performance

Apache MaxClients
Apache MaxClients

MaxClients Apache configuration directive determines overall sociability of your web server. Thus it is really important that you set this directive to an appropriate value. Setting MaxClients directive without system assessment may result into unstable system and crash.

This directive controls how many simultaneous connections can be served. Any connection request from browsers that come in after that will be queued.

Tuning the Apache MaxClients parameter

One of the most critical hardware issue that affects your web server performance is RAM. If all the RAM is being consumed up by the Apache web server, system starts swapping. A web-server should never ever have to swap, as swapping increases the latency of each request beyond a point that users consider “fast enough”. This results into users hitting stop and reload, which in return further increases the load. You can, and should, control the¬†MaxClients setting so that your server does not spawn so many children it starts swapping.

You can also learn to tweak some other directives of Apache web server to optimize its performance.

Apache performance tuning

Determine the size of your average Apache process

In order to set MaxClients directive correctly we first need to know the average size of Apache processes in your system. Size of your Apache process mainly depends upon your web application. Use the following command to get the average size of Apache process.

#ps -ylC apache2 –sort:rss

or

#ps -ylC httpd –sort:rss

As you can see in the SZ column, my Apache process size is about 23 MB

Apache Process Size

Use the following formula:

MaxClients: ((Total_Memory)(1024)(MB) – Other_processes_memory) / 23

For Instance: I have 16 GB RAM, I might leave 2 GB free for any other processes.

MaxClients: ((16*1024) - 2048) / 23

MaxClients: 623

Setting up Apache MaxClients directive value.

Navigate to the file /etc/apache2/apache2.conf file on Debian/Ubuntu, and the /etc/httpd/conf/httpd.conf file on CentOS/Fedora.

Now change the value of MaxClients parameter in configuration file.

About the author

Ajay Verma

A Computer Science Graduate, who works extensively on open source projects. His Areas Of interest are: Network Security, Linux Administration, FOSS, Python, and C programming.

Add Comment

Click here to post a comment

Follow us here!