2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
7 Licensed to the Apache Software Foundation (ASF) under one or more
8 contributor license agreements. See the NOTICE file distributed with
9 this work for additional information regarding copyright ownership.
10 The ASF licenses this file to You under the Apache License, Version 2.0
11 (the "License"); you may not use this file except in compliance with
12 the License. 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. Each server process may answer incoming
34 requests, and a parent process manages the size of the server pool.
35 It is appropriate for sites that need to avoid
36 threading for compatibility with non-thread-safe libraries. It
37 is also the best MPM for isolating each request, so that a problem
38 with a single request will not affect any other.</p>
40 <p>This MPM is very self-regulating, so it is rarely necessary to
41 adjust its configuration directives. Most important is that
42 <directive module="mpm_common">MaxClients</directive> be big enough to
43 handle as many simultaneous requests as you expect to receive, but
44 small enough to assure that there is enough physical RAM for all
47 <seealso><a href="../bind.html">Setting which addresses and ports Apache HTTP Server
50 <section id="how-it-works"><title>How it Works</title>
51 <p>A single control process is responsible for launching child
52 processes which listen for connections and serve them when they
53 arrive. Apache httpd always tries to maintain several <dfn>spare</dfn>
54 or idle server processes, which stand ready to serve incoming
55 requests. In this way, clients do not need to wait for a new
56 child processes to be forked before their requests can be
59 <p>The <directive module="mpm_common">StartServers</directive>,
60 <directive module="prefork">MinSpareServers</directive>,
61 <directive module="prefork">MaxSpareServers</directive>, and
62 <directive module="mpm_common">MaxClients</directive> regulate how
63 the parent process creates children to serve requests. In general,
64 Apache httpd is very self-regulating, so most sites do not need to
65 adjust these directives from their default values. Sites which
66 need to serve more than 256 simultaneous requests may need to
67 increase <directive module="mpm_common">MaxClients</directive>,
68 while sites with limited memory may need to decrease <directive
69 module="mpm_common">MaxClients</directive> to keep the server from
70 thrashing (swapping memory to disk and back). More information
71 about tuning process creation is provided in the <a
72 href="../misc/perf-tuning.html">performance hints</a>
75 <p>While the parent process is usually started as <code>root</code>
76 under Unix in order to bind to port 80, the child processes are
77 launched by Apache httpd as a less-privileged user. The <directive
78 module="mod_unixd">User</directive> and <directive
79 module="mod_unixd">Group</directive> directives are used to set
80 the privileges of the Apache httpd child processes. The child processes
81 must be able to read all the content that will be served, but
82 should have as few privileges beyond that as possible.</p>
84 <p><directive module="mpm_common">MaxConnectionsPerChild</directive>
85 controls how frequently the server recycles processes by killing
86 old ones and launching new ones.</p>
88 <p>This MPM uses the <code>mpm-accept</code> mutex to serialize
89 access to incoming connections when subject to the thundering herd
90 problem (generally, when there are multiple listening sockets).
91 The implementation aspects of this mutex can be configured with the
92 <directive module="core">Mutex</directive> directive. The <a
93 href="../misc/perf-tuning.html">performance hints</a>
94 documentation has additional information about this mutex.</p>
97 <directivesynopsis location="mpm_common"><name>CoreDumpDirectory</name>
99 <directivesynopsis location="mpm_common"><name>EnableExceptionHook</name>
101 <directivesynopsis location="mpm_common"><name>PidFile</name>
103 <directivesynopsis location="mpm_common"><name>Listen</name>
105 <directivesynopsis location="mpm_common"><name>ListenBacklog</name>
107 <directivesynopsis location="mpm_common"><name>MaxClients</name>
109 <directivesynopsis location="mpm_common"><name>MaxMemFree</name>
111 <directivesynopsis location="mpm_common"><name>MaxConnectionsPerChild</name>
113 <directivesynopsis location="mpm_common"><name>ScoreBoardFile</name>
115 <directivesynopsis location="mpm_common"><name>ReceiveBufferSize</name>
117 <directivesynopsis location="mpm_common"><name>SendBufferSize</name>
119 <directivesynopsis location="mpm_common"><name>ServerLimit</name>
121 <directivesynopsis location="mpm_common"><name>StartServers</name>
123 <directivesynopsis location="mod_unixd"><name>User</name>
125 <directivesynopsis location="mod_unixd"><name>Group</name>
129 <name>MaxSpareServers</name>
130 <description>Maximum number of idle child server processes</description>
131 <syntax>MaxSpareServers <var>number</var></syntax>
132 <default>MaxSpareServers 10</default>
133 <contextlist><context>server config</context></contextlist>
136 <p>The <directive>MaxSpareServers</directive> directive sets the
137 desired maximum number of <em>idle</em> child server processes. An
138 idle process is one which is not handling a request. If there are
139 more than <directive>MaxSpareServers</directive> idle, then the
140 parent process will kill off the excess processes.</p>
142 <p>Tuning of this parameter should only be necessary on very
143 busy sites. Setting this parameter to a large number is almost
144 always a bad idea. If you are trying to set the value equal to or lower than
145 <directive module="prefork">MinSpareServers</directive>, Apache HTTP Server
146 will automatically adjust it to <directive
147 >MinSpareServers</directive><code> + 1</code>.</p>
149 <seealso><directive module="prefork">MinSpareServers</directive></seealso>
150 <seealso><directive module="mpm_common">StartServers</directive></seealso>
151 <seealso><directive module="mpm_common">MaxSpareThreads</directive></seealso>
155 <name>MinSpareServers</name>
156 <description>Minimum number of idle child server processes</description>
157 <syntax>MinSpareServers <var>number</var></syntax>
158 <default>MinSpareServers 5</default>
159 <contextlist><context>server config</context></contextlist>
162 <p>The <directive>MinSpareServers</directive> directive sets the
163 desired minimum number of <em>idle</em> child server processes. An
164 idle process is one which is not handling a request. If there are
165 fewer than <directive>MinSpareServers</directive> idle, then the parent
166 process creates new children at a maximum rate of 1 per second.</p>
168 <p>Tuning of this parameter should only be necessary on very
169 busy sites. Setting this parameter to a large number is almost
170 always a bad idea.</p>
172 <seealso><directive module="prefork">MaxSpareServers</directive></seealso>
173 <seealso><directive module="mpm_common">StartServers</directive></seealso>
174 <seealso><directive module="mpm_common">MinSpareThreads</directive></seealso>