Apache performance tips


If Apache 2.0 is running on several Linux boxes behind a load balancer, here are a couple of things you can do to speed things up.

1. Disable RedirectMatch directives temporarily

2. Increase MaxClients and ServerLimit

This is a well-known Apache performance optimization tip. Its effect is to increase the number of httpd processes available to service the HTTP requests.

The 2 entries in httpd.conf, in IfModule prefork.c section are:

MaxClients 1000
ServerLimit 1000

Now there is a procedure for tuning the number of httpd processes on a given box:

1. Start small, with the default MaxClients (150).
2. If Apache seems sluggish, start increasing both MaxClients and ServerLimit; restart httpd every time you do this.
3. Monitor the number of httpd processes; you can use something like:

ps -def | grep httpd | grep -v grep | wc -l

If the number of httpd processes becomes equal to the MaxClients limit you specified in httpd.conf, check your CPU and memory (via top or vmstat). If the system is not yet overloaded, go to step 2. If the system is overloaded, it’s time to put another server in the server farm behind the load balancer.

WARNING: MaxClients of 1000 exceeds ServerLimit value of 256 servers, lowering MaxClients to 256. To increase, please see the ServerLimit directive.

To avoid above warning, You need to put the Serverlimit option before the maxclient in the apache config file.

Example config:

IfModule prefork.c

StartServers 20
MinSpareServers 5
MaxSpareServers 20

ServerLimit 1024 <====—— moved this line here rather than after the
Maxclients (otherwise Apache will gives error, “WARNING: MaxClients of 1000
exceeds ServerLimit value of 256 servers, lowering MaxClients to 256. To
increase, please see the ServerLimit directive”)

MaxClients 512 <====——– changed from 256 to 512

MaxRequestsPerChild 10000

IfModule

Related Posts: