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