2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
7 Copyright 2002-2005 The Apache Software Foundation or its licensors, as
10 Licensed under the Apache License, Version 2.0 (the "License");
11 you may not use this file except in compliance with the License.
12 You may obtain a copy of the License at
14 http://www.apache.org/licenses/LICENSE-2.0
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
23 <modulesynopsis metafile="prefork.xml.meta">
26 <description>Implements a non-threaded, pre-forking web server</description>
28 <sourcefile>prefork.c</sourcefile>
29 <identifier>mpm_prefork_module</identifier>
32 <p>This Multi-Processing Module (MPM) implements a non-threaded,
33 pre-forking web server that handles requests in a manner similar
34 to Apache 1.3. It is appropriate for sites that need to avoid
35 threading for compatibility with non-thread-safe libraries. It
36 is also the best MPM for isolating each request, so that a problem
37 with a single request will not affect any other.</p>
39 <p>This MPM is very self-regulating, so it is rarely necessary to
40 adjust its configuration directives. Most important is that
41 <directive module="mpm_common">MaxClients</directive> be big enough to
42 handle as many simultaneous requests as you expect to receive, but
43 small enough to assure that there is enough physical RAM for all
46 <seealso><a href="../bind.html">Setting which addresses and ports Apache
49 <section id="how-it-works"><title>How it Works</title>
50 <p>A single control process is responsible for launching child
51 processes which listen for connections and serve them when they
52 arrive. Apache always tries to maintain several <dfn>spare</dfn>
53 or idle server processes, which stand ready to serve incoming
54 requests. In this way, clients do not need to wait for a new
55 child processes to be forked before their requests can be
58 <p>The <directive module="mpm_common">StartServers</directive>,
59 <directive module="prefork">MinSpareServers</directive>,
60 <directive module="prefork">MaxSpareServers</directive>, and
61 <directive module="mpm_common">MaxClients</directive> regulate how
62 the parent process creates children to serve requests. In general,
63 Apache is very self-regulating, so most sites do not need to
64 adjust these directives from their default values. Sites which
65 need to serve more than 256 simultaneous requests may need to
66 increase <directive module="mpm_common">MaxClients</directive>,
67 while sites with limited memory may need to decrease <directive
68 module="mpm_common">MaxClients</directive> to keep the server from
69 thrashing (swapping memory to disk and back). More information
70 about tuning process creation is provided in the <a
71 href="../misc/perf-tuning.html">performance hints</a>
74 <p>While the parent process is usually started as <code>root</code>
75 under Unix in order to bind to port 80, the child processes are
76 launched by Apache as a less-privileged user. The <directive
77 module="mpm_common">User</directive> and <directive
78 module="mpm_common">Group</directive> directives are used to set
79 the privileges of the Apache child processes. The child processes
80 must be able to read all the content that will be served, but
81 should have as few privileges beyond that as possible.</p>
83 <p><directive module="mpm_common">MaxRequestsPerChild</directive>
84 controls how frequently the server recycles processes by killing
85 old ones and launching new ones.</p>
88 <directivesynopsis location="mpm_common"><name>CoreDumpDirectory</name>
90 <directivesynopsis location="mpm_common"><name>EnableExceptionHook</name>
92 <directivesynopsis location="mpm_common"><name>PidFile</name>
94 <directivesynopsis location="mpm_common"><name>Listen</name>
96 <directivesynopsis location="mpm_common"><name>ListenBacklog</name>
98 <directivesynopsis location="mpm_common"><name>LockFile</name>
100 <directivesynopsis location="mpm_common"><name>MaxClients</name>
102 <directivesynopsis location="mpm_common"><name>MaxMemFree</name>
104 <directivesynopsis location="mpm_common"><name>MaxRequestsPerChild</name>
106 <directivesynopsis location="mpm_common"><name>ScoreBoardFile</name>
108 <directivesynopsis location="mpm_common"><name>ReceiveBufferSize</name>
110 <directivesynopsis location="mpm_common"><name>SendBufferSize</name>
112 <directivesynopsis location="mpm_common"><name>ServerLimit</name>
114 <directivesynopsis location="mpm_common"><name>StartServers</name>
116 <directivesynopsis location="mpm_common"><name>User</name>
118 <directivesynopsis location="mpm_common"><name>Group</name>
120 <directivesynopsis location="mpm_common"><name>AcceptMutex</name>
124 <name>MaxSpareServers</name>
125 <description>Maximum number of idle child server processes</description>
126 <syntax>MaxSpareServers <var>number</var></syntax>
127 <default>MaxSpareServers 10</default>
128 <contextlist><context>server config</context></contextlist>
131 <p>The <directive>MaxSpareServers</directive> directive sets the
132 desired maximum number of <em>idle</em> child server processes. An
133 idle process is one which is not handling a request. If there are
134 more than <directive>MaxSpareServers</directive> idle, then the
135 parent process will kill off the excess processes.</p>
137 <p>Tuning of this parameter should only be necessary on very
138 busy sites. Setting this parameter to a large number is almost
139 always a bad idea. If you are trying to set the value equal to or lower than
140 <directive module="prefork">MinSpareServers</directive>, Apache
141 will automatically adjust it to <directive
142 >MinSpareServers</directive><code> + 1</code>.</p>
144 <seealso><directive module="prefork">MinSpareServers</directive></seealso>
145 <seealso><directive module="mpm_common">StartServers</directive></seealso>
149 <name>MinSpareServers</name>
150 <description>Minimum number of idle child server processes</description>
151 <syntax>MinSpareServers <var>number</var></syntax>
152 <default>MinSpareServers 5</default>
153 <contextlist><context>server config</context></contextlist>
156 <p>The <directive>MinSpareServers</directive> directive sets the
157 desired minimum number of <em>idle</em> child server processes. An
158 idle process is one which is not handling a request. If there are
159 fewer than <directive>MinSpareServers</directive> idle, then the parent
160 process creates new children at a maximum rate of 1 per second.</p>
162 <p>Tuning of this parameter should only be necessary on very
163 busy sites. Setting this parameter to a large number is almost
164 always a bad idea.</p>
166 <seealso><directive module="prefork">MaxSpareServers</directive></seealso>
167 <seealso><directive module="mpm_common">StartServers</directive></seealso>