]> granicus.if.org Git - apache/blob - docs/manual/mod/prefork.xml
Merge in APR[-util] macros from branches/trunk-buildconf-noapr
[apache] / docs / manual / mod / prefork.xml
1 <?xml version="1.0"?>
2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
5
6 <!--
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
13
14      http://www.apache.org/licenses/LICENSE-2.0
15
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.
21 -->
22
23 <modulesynopsis metafile="prefork.xml.meta">
24
25 <name>prefork</name>
26 <description>Implements a non-threaded, pre-forking web server</description>
27 <status>MPM</status>
28 <sourcefile>prefork.c</sourcefile>
29 <identifier>mpm_prefork_module</identifier>
30
31 <summary>
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>
39
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">MaxRequestWorkers</directive> be big enough
43     to handle as many simultaneous requests as you expect to receive, but
44     small enough to assure that there is enough physical RAM for all
45     processes.</p>
46 </summary>
47 <seealso><a href="../bind.html">Setting which addresses and ports Apache HTTP Server
48 uses</a></seealso>
49
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
57     served.</p>
58
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">MaxRequestWorkers</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">MaxRequestWorkers</directive>,
68     while sites with limited memory may need to decrease <directive
69     module="mpm_common">MaxRequestWorkers</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>
73     documentation.</p>
74
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>
83
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>
87
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>
95 </section>
96
97 <directivesynopsis location="mpm_common"><name>CoreDumpDirectory</name>
98 </directivesynopsis>
99 <directivesynopsis location="mpm_common"><name>EnableExceptionHook</name>
100 </directivesynopsis>
101 <directivesynopsis location="mpm_common"><name>PidFile</name>
102 </directivesynopsis>
103 <directivesynopsis location="mpm_common"><name>Listen</name>
104 </directivesynopsis>
105 <directivesynopsis location="mpm_common"><name>ListenBacklog</name>
106 </directivesynopsis>
107 <directivesynopsis location="mpm_common"><name>MaxRequestWorkers</name>
108 </directivesynopsis>
109 <directivesynopsis location="mpm_common"><name>MaxMemFree</name>
110 </directivesynopsis>
111 <directivesynopsis location="mpm_common"><name>MaxConnectionsPerChild</name>
112 </directivesynopsis>
113 <directivesynopsis location="mpm_common"><name>ScoreBoardFile</name>
114 </directivesynopsis>
115 <directivesynopsis location="mpm_common"><name>ReceiveBufferSize</name>
116 </directivesynopsis>
117 <directivesynopsis location="mpm_common"><name>SendBufferSize</name>
118 </directivesynopsis>
119 <directivesynopsis location="mpm_common"><name>ServerLimit</name>
120 </directivesynopsis>
121 <directivesynopsis location="mpm_common"><name>StartServers</name>
122 </directivesynopsis>
123 <directivesynopsis location="mod_unixd"><name>User</name>
124 </directivesynopsis>
125 <directivesynopsis location="mod_unixd"><name>Group</name>
126 </directivesynopsis>
127
128 <directivesynopsis>
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>
134
135 <usage>
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>
141
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>
148 </usage>
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>
152 </directivesynopsis>
153
154 <directivesynopsis>
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>
160
161 <usage>
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: It will spawn one, wait a second, then spawn
167     two, wait a second, then spawn four, and it will
168     continue exponentially until it is spawning 32 children per second. It will
169     stop whenever it satisfies the <directive>MinSpareServers</directive>
170     setting.</p>
171
172     <p>Tuning of this parameter should only be necessary on very
173     busy sites. Setting this parameter to a large number is almost
174     always a bad idea.</p>
175 </usage>
176 <seealso><directive module="prefork">MaxSpareServers</directive></seealso>
177 <seealso><directive module="mpm_common">StartServers</directive></seealso>
178 <seealso><directive module="mpm_common">MinSpareThreads</directive></seealso>
179 </directivesynopsis>
180
181 </modulesynopsis>
182