pavement

Apache, Configuring

From FreeBSDwiki
(Difference between revisions)
Jump to: navigation, search
(Prefork)
(MPM)
Line 8: Line 8:
 
  ## Server-Pool Size Regulation (MPM specific)
 
  ## Server-Pool Size Regulation (MPM specific)
 
  ##
 
  ##
 +
 +
Read more about what an MPM is here: http://httpd.apache.org/docs/2.0/mpm.html.
  
 
===Prefork===
 
===Prefork===

Revision as of 15:26, 20 October 2005

If you've got a busy webserver, you'll soon find yourself looking at tweaking the Apache configuration to get more. As it is, most Apache installs are configured for testing / development vs production use.

Contents

MPM

By default, the httpd.conf has MPM specific settings for all possible MPM choices. However, since this choice is made at compile-time, all but one of these MPM specific can be safely removed. The default (and usually the recommended) MPM is prefork.

##
## Server-Pool Size Regulation (MPM specific)
##

Read more about what an MPM is here: http://httpd.apache.org/docs/2.0/mpm.html.

Prefork

This is the default MPM and will work fine for most applications.

Default:

# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule prefork.c>
StartServers         5
MinSpareServers      5
MaxSpareServers     10
MaxClients         150
MaxRequestsPerChild  0
</IfModule>

Tweaked:

StartServers        10
MinSpareServers     10
MaxSpareServers     20
MaxClients         256
MaxRequestsPerChild 15000

StartServers, MinSpareServers, MaxSpareServers Creating a child process can be one of the most expensive in terms of CPU usage. Experiment with raising these values... as a start, you can probably safely double them and go from there. During traffic spikes, the server will have more available, idle child processes already created, which should help reduce load and keep the server busier serving content than spawning new servers when needed.

MaxClients With a busy website you may start reaching the default MaxClients, in which case everyone else is locked out. This error will show up in your error logs. Please note that there is a hard limit of 256 for this directive. Raising it requires setting a compile-time option and reinstalling. Still, 256 is much heftier than 150, so this may work out fine.

MaxRequestsPerChild Leaving this at 0 means a child never dies... once its created it will serve an unlimited number of requests until the main daemon kills it off during traffic lulls. Setting this to a high number has the benefit of periodically refreshing the pool of child processes and keeping memory leakage to a minimum.

Worker

In order to try out the worker MPM, you must re-install Apache2 with different MAKE_ARGS. For the brave, please see this page: Apache2 with the Worker MPM.

KeepAlives

The KeepAlives directive is enabled by default; to quote from the Apache documentation:

The Keep-Alive extension to HTTP/1.0 and the persistent connection feature of 
HTTP/1.1 provide long-lived HTTP sessions which allow multiple requests to be 
sent over the same TCP connection. In some cases this has been shown to result
in an almost 50% speedup in latency times for HTML documents with many images. 

Which is a good thing, if you want fast pages and have a strong server to handle it. If you're more concerned with availability than speed, or are running Apache on a less-than-stellar machine, you may get better performance (cpu/processor-wise, at least,) by turning KeepAlives off:

Default:

KeepAlives On

Tweaked:

KeepAlives Off
Personal tools