[CentOS] Apache Server Tuning for Performance

Les Mikesell lesmikesell at gmail.com
Tue Jan 20 19:56:37 UTC 2009


Jed Reynolds wrote:
> 
> Merely increasing the number of workers might make performance worse.
> 
> Use ps or top to figure out how much each apache worker is using. Then 
> decide how much ram you want to dedicate on your server to Apache, 
> without going into swap. (Over-allocating and then paging out memory 
> will only make performance much worse.)  For example, if I have 2G or
> ram, and I want 1.5 for apache workers, my average apache worker size 
> (resident memory) is 65MB, then I have room for 23 workers. (1024 * 1.5 
> ) / 65. (There are more accurate ways to calculate this usage, like 
> taking shared memory into account.)

Pay attention to shared memory when doing this.  A freshly-forked 
process shares virtually all RAM with its parent.  How much and how 
quickly this changes varies wildly with the application type and 
activity that causes the child's data to become unique.  With some types 
of applications (especially mod_perl) you may want to tune down the 
number of hits each child services to increase memory sharing.  Also, if 
you are running external cgi programs you must take them into account.

> Upgrading the ram in your web server is a pretty fast interim solution.
> 
> Consider your application performance, too. The longer a request in your 
> application takes, the more workers are in use on your web server, 
> taking up more memory. If you have long-running queries in your 
> database, take care of those first.

You may also have to turn off or tune down the HTTP 1.1 connection 
keepalives, trading the time it takes to establish a new connection for 
the RAM it takes to keep the associated process waiting for another 
request from the same client.

-- 
   Les Mikesell
    lesmikesell at gmail.com



More information about the CentOS mailing list