You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Nick <ni...@finiteautomata.com> on 2004/05/27 04:51:50 UTC

[users@httpd] Performance tweaks

Hello, I am trying to tweak Apache 2.0.49.  I recently updated from 1.3 and had some questions about tuning thread creation on my RedHat Ent. 3 boxes.  Each box is a 2.4 dual Xeon with 2gb of RAM and runs about 30 sites.  I have 8 boxes load balanced using a Cisco GSS.
I compiled Apache using "--with-mpm=worker" because I figured that this would be best for us due to heavy loads and I am not worried about backward compatibility.  I am confused about my worker MPM configuration.  Using the default worker MPM configuration my average Apache process seems to be about 9mbs (I get this info from top and ps -ef)  On average there are about 12 processes running.  Since I have roughly 2000megs of RAM divided by 9megs (process average) = 222, so I would say set the Max Clients to 200 giving me some room to spare so I don't start using swap (right? this is the way I use to do it).
In the O'Reilly Apache Cookbook I read that ServerLimit should not exceed my RAM when ServerLimit is multiplied by the size of the average process.  So I want SeverLimit to equal something less than 9 x ? <= 2000, wouldn't that be something close to 200.  That doesn't seem right, I don't want to set my ServerLimit that high do I?  It also says that I want MaxClients less than ServerLimit x ThreadsPerChild.  In the books example they have
StartServers   2
MaxClients   150
MinSpareThreads   25
MaxSpareThreads   75
ThreadsPerChild   25
ServerLimit   16
If I multiply ServerLimit x ThreadsPerChild it does not equal to or is less than MaxClients.  16 x 25 = 400.
In my conf file I also see the PreFork setting in there - how do I know which MPM Apache is using?  Is the worker better for heavy loads and occasional spikes?
How do I figure out the best settings for my server?  I would guess that I want to make the MaxClients something like 175 because 175 x 9 =1575, which gives me some spare RAM.  How do I determine my StartServers setting?  I also would guess I want my MaxSpareThreads a little higher than 75, something like 85 or 90, is this right?  If I choose MaxSpare = 90, should MinSpare = 30?  I also think Max and Min need to be able to be divided into MaxClients so I would make MaxClients = 180.  Does this sound right?  What should the StartServers be and what should the ServerLimit be or should I define a ServerLimit?

Thanks,
Nick


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Performance tweaks

Posted by Joshua Slive <jo...@slive.ca>.
On Wed, 26 May 2004, Nick wrote:
> I compiled Apache using "--with-mpm=worker" because I figured that this 
> would be best for us due to heavy loads and I am not worried about 
> backward compatibility.  I am confused about my worker MPM 
> configuration.  Using the default worker MPM configuration my average 
> Apache process seems to be about 9mbs (I get this info from top and ps 
> -ef)  On average there are about 12 processes running.  Since I have 
> roughly 2000megs of RAM divided by 9megs (process average) = 222, so I 
> would say set the Max Clients to 200 giving me some room to spare so I 
> don't start using swap (right? this is the way I use to do it).

> In the O'Reilly Apache Cookbook I read that ServerLimit should not 
> exceed my RAM when ServerLimit is multiplied by the size of the average 
> process.  So I want SeverLimit to equal something less than 9 x ? <= 
> 2000, wouldn't that be something close to 200.  That doesn't seem right, 
> I don't want to set my ServerLimit that high do I?  It also says that I 
> want MaxClients less than ServerLimit x ThreadsPerChild.  In the books 
> example they have

> StartServers   2
> MaxClients   150
> MinSpareThreads   25
> MaxSpareThreads   75
> ThreadsPerChild   25
> ServerLimit   16

> If I multiply ServerLimit x ThreadsPerChild it does not equal to or is 
> less than MaxClients.  16 x 25 = 400.

Hmmm... This stuff isn't simple, (many of the directives are 
confusingly named) but I don't think you have exactly the 
right idea.  See:
http://httpd.apache.org/docs-2.0/mod/worker.html

There you'll find that MaxClients refers to the number of worker *threads* 
available.  So if you have "ThreadsPerChild 25" and you have room in 
memory for 200 process, that means that you can have up to 25*200 = 5000 
worker threads, so MaxClients should be 5000.  (I recommend not setting it 
that high until you have tested at lower levels.)

SeverLimit, on the other hand, refers to the number of child *processes*. 
So ServerLimit in this case should be *at least* 200.  ServerLimit must 
*exceed* MaxClients times ThreadsPerChild.  In general, ServerLimit is not 
an important directive.  It only sets the maximum size of some internal 
structures.  So you should just set this relatively high, and then play 
with MaxClients to find the load that your servers can support.

> In my conf file I also see the PreFork setting in there - how do I know 
> which MPM Apache is using?

httpd -l

> Is the worker better for heavy loads and 
> occasional spikes?

Theoretically, yes.  Worker should be more memory efficient because of its 
use of threads.  But alot of this depends on the efficiency of the thread 
library.  I don't know much about linux threading, but I do know that only 
the newest linux thread libraries really provide any significant advantage 
over processes.

> How do I figure out the best settings for my server?

There is no easy answer for this.  Experimentation and testing, I guess. 
It sounds like you are starting in the right direction, however, by 
measuring memory usage to calculate theoretical maximums.

> How do I determine my StartServers setting?

StartServers is relatively unimportant.  Just estimate the typical load 
you expect the server to face immediately after startup, and then divide 
that by ThreadsPerChild (and take the next lowest integer).

> I also would guess I want my MaxSpareThreads a little higher 
> than 75, something like 85 or 90, is this right?  If I choose MaxSpare = 
> 90, should MinSpare = 30?  I also think Max and Min need to be able to 
> be divided into MaxClients so I would make MaxClients = 180.

This depends on how quickly you need the server to respond to load spikes. 
But again, these directives are not crucial, since Apache will respond 
relatively quickly regardless.  You should set Max/MinSpareThreads to be 
multiples of ThreadsPerChild.  If the box is dedicated to web serving (so 
you don't care about the web server using excess memory during quiet 
periods), then you can set MaxSpareThreads relatively high. 
MinSpareThreads should probably not be set much higher than 
2*ThreadsPerChild, since you don't want to force the server to be 
constantly keeping a bunch of idle threads, even during high loads.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org