fc88db23cb4b205f1efea5f5d5ae916589db5a61slive<?xml version="1.0"?>
efa4f29a7761c2123557276566f45c9084e734c6patrikj<!DOCTYPE modulesynopsis SYSTEM "/style/modulesynopsis.dtd">
e942c741056732f50da2074b36fe59805d370650slive<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
5f5d1b4cc970b7f06ff8ef6526128e9a27303d88nd<!-- $LastChangedRevision$ -->
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd<!--
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding Licensed to the Apache Software Foundation (ASF) under one or more
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding contributor license agreements. See the NOTICE file distributed with
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding this work for additional information regarding copyright ownership.
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding The ASF licenses this file to You under the Apache License, Version 2.0
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding (the "License"); you may not use this file except in compliance with
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding the License. You may obtain a copy of the License at
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd http://www.apache.org/licenses/LICENSE-2.0
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd Unless required by applicable law or agreed to in writing, software
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd distributed under the License is distributed on an "AS IS" BASIS,
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd See the License for the specific language governing permissions and
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd limitations under the License.
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd-->
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd
7db9f691a00ead175b03335457ca296a33ddf31bnd<modulesynopsis metafile="prefork.xml.meta">
efa4f29a7761c2123557276566f45c9084e734c6patrikj
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive<name>prefork</name>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive<description>Implements a non-threaded, pre-forking web server</description>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive<status>MPM</status>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive<sourcefile>prefork.c</sourcefile>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive<identifier>mpm_prefork_module</identifier>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive<summary>
1a9d040bd97b9bacbcb5aead589523bf60572e04slive <p>This Multi-Processing Module (MPM) implements a non-threaded,
55478342807b8fbc71ba2af7444e3a06fad7ebf1rbowen pre-forking web server. Each server process may answer incoming
55478342807b8fbc71ba2af7444e3a06fad7ebf1rbowen requests, and a parent process manages the size of the server pool.
55478342807b8fbc71ba2af7444e3a06fad7ebf1rbowen It is appropriate for sites that need to avoid
1a9d040bd97b9bacbcb5aead589523bf60572e04slive threading for compatibility with non-thread-safe libraries. It
1a9d040bd97b9bacbcb5aead589523bf60572e04slive is also the best MPM for isolating each request, so that a problem
1a9d040bd97b9bacbcb5aead589523bf60572e04slive with a single request will not affect any other.</p>
1a9d040bd97b9bacbcb5aead589523bf60572e04slive
1a9d040bd97b9bacbcb5aead589523bf60572e04slive <p>This MPM is very self-regulating, so it is rarely necessary to
1a9d040bd97b9bacbcb5aead589523bf60572e04slive adjust its configuration directives. Most important is that
3fa816e4832a1c70600bdfd6fc5ef60e9f1c18bbsf <directive module="mpm_common">MaxRequestWorkers</directive> be big enough
3fa816e4832a1c70600bdfd6fc5ef60e9f1c18bbsf to handle as many simultaneous requests as you expect to receive, but
1a9d040bd97b9bacbcb5aead589523bf60572e04slive small enough to assure that there is enough physical RAM for all
1a9d040bd97b9bacbcb5aead589523bf60572e04slive processes.</p>
1a9d040bd97b9bacbcb5aead589523bf60572e04slive</summary>
55478342807b8fbc71ba2af7444e3a06fad7ebf1rbowen<seealso><a href="/bind.html">Setting which addresses and ports Apache HTTP Server
9cd774340b4867bf4803ab6998450c8d39d0c0c3nduses</a></seealso>
1a9d040bd97b9bacbcb5aead589523bf60572e04slive
ea8a727ff298d2f5368b55b7ae8d87091ae106e7nd<section id="how-it-works"><title>How it Works</title>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive <p>A single control process is responsible for launching child
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive processes which listen for connections and serve them when they
55478342807b8fbc71ba2af7444e3a06fad7ebf1rbowen arrive. Apache httpd always tries to maintain several <dfn>spare</dfn>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive or idle server processes, which stand ready to serve incoming
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive requests. In this way, clients do not need to wait for a new
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive child processes to be forked before their requests can be
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive served.</p>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive <p>The <directive module="mpm_common">StartServers</directive>,
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive <directive module="prefork">MinSpareServers</directive>,
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive <directive module="prefork">MaxSpareServers</directive>, and
3fa816e4832a1c70600bdfd6fc5ef60e9f1c18bbsf <directive module="mpm_common">MaxRequestWorkers</directive> regulate how
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive the parent process creates children to serve requests. In general,
55478342807b8fbc71ba2af7444e3a06fad7ebf1rbowen Apache httpd is very self-regulating, so most sites do not need to
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive adjust these directives from their default values. Sites which
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive need to serve more than 256 simultaneous requests may need to
3fa816e4832a1c70600bdfd6fc5ef60e9f1c18bbsf increase <directive module="mpm_common">MaxRequestWorkers</directive>,
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive while sites with limited memory may need to decrease <directive
3fa816e4832a1c70600bdfd6fc5ef60e9f1c18bbsf module="mpm_common">MaxRequestWorkers</directive> to keep the server from
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive thrashing (swapping memory to disk and back). More information
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive about tuning process creation is provided in the <a
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive href="/misc/perf-tuning.html">performance hints</a>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive documentation.</p>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive
9cd774340b4867bf4803ab6998450c8d39d0c0c3nd <p>While the parent process is usually started as <code>root</code>
9cd774340b4867bf4803ab6998450c8d39d0c0c3nd under Unix in order to bind to port 80, the child processes are
55478342807b8fbc71ba2af7444e3a06fad7ebf1rbowen launched by Apache httpd as a less-privileged user. The <directive
4c894c7d7c34890a8984b6cc1bcf6c19f15c4c0aniq module="mod_unixd">User</directive> and <directive
4c894c7d7c34890a8984b6cc1bcf6c19f15c4c0aniq module="mod_unixd">Group</directive> directives are used to set
55478342807b8fbc71ba2af7444e3a06fad7ebf1rbowen the privileges of the Apache httpd child processes. The child processes
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive must be able to read all the content that will be served, but
1a9d040bd97b9bacbcb5aead589523bf60572e04slive should have as few privileges beyond that as possible.</p>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive
be192cefa381d5bae6868034687471754cb43175sf <p><directive module="mpm_common">MaxConnectionsPerChild</directive>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive controls how frequently the server recycles processes by killing
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive old ones and launching new ones.</p>
bf0e7f6393e91c0a7c15cb0d889a4238c973dc2etrawick
bf0e7f6393e91c0a7c15cb0d889a4238c973dc2etrawick <p>This MPM uses the <code>mpm-accept</code> mutex to serialize
bf0e7f6393e91c0a7c15cb0d889a4238c973dc2etrawick access to incoming connections when subject to the thundering herd
bf0e7f6393e91c0a7c15cb0d889a4238c973dc2etrawick problem (generally, when there are multiple listening sockets).
bf0e7f6393e91c0a7c15cb0d889a4238c973dc2etrawick The implementation aspects of this mutex can be configured with the
bf0e7f6393e91c0a7c15cb0d889a4238c973dc2etrawick <directive module="core">Mutex</directive> directive. The <a
bf0e7f6393e91c0a7c15cb0d889a4238c973dc2etrawick href="/misc/perf-tuning.html">performance hints</a>
bf0e7f6393e91c0a7c15cb0d889a4238c973dc2etrawick documentation has additional information about this mutex.</p>
1a9d040bd97b9bacbcb5aead589523bf60572e04slive</section>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive
9cd774340b4867bf4803ab6998450c8d39d0c0c3nd<directivesynopsis location="mpm_common"><name>CoreDumpDirectory</name>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive</directivesynopsis>
e0bc3354c7c500594dae31ba0ae09818c7fd77c0nd<directivesynopsis location="mpm_common"><name>EnableExceptionHook</name>
e0bc3354c7c500594dae31ba0ae09818c7fd77c0nd</directivesynopsis>
9cd774340b4867bf4803ab6998450c8d39d0c0c3nd<directivesynopsis location="mpm_common"><name>PidFile</name>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive</directivesynopsis>
9cd774340b4867bf4803ab6998450c8d39d0c0c3nd<directivesynopsis location="mpm_common"><name>Listen</name>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive</directivesynopsis>
9cd774340b4867bf4803ab6998450c8d39d0c0c3nd<directivesynopsis location="mpm_common"><name>ListenBacklog</name>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive</directivesynopsis>
3fa816e4832a1c70600bdfd6fc5ef60e9f1c18bbsf<directivesynopsis location="mpm_common"><name>MaxRequestWorkers</name>
aec7c8cf914c36561c73aee001924daa6ce7a21btrawick</directivesynopsis>
9cd774340b4867bf4803ab6998450c8d39d0c0c3nd<directivesynopsis location="mpm_common"><name>MaxMemFree</name>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive</directivesynopsis>
be192cefa381d5bae6868034687471754cb43175sf<directivesynopsis location="mpm_common"><name>MaxConnectionsPerChild</name>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive</directivesynopsis>
9cd774340b4867bf4803ab6998450c8d39d0c0c3nd<directivesynopsis location="mpm_common"><name>ScoreBoardFile</name>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive</directivesynopsis>
cc934828f4a719743a3387516f6fa71dd2cc88ffstas<directivesynopsis location="mpm_common"><name>ReceiveBufferSize</name>
cc934828f4a719743a3387516f6fa71dd2cc88ffstas</directivesynopsis>
9cd774340b4867bf4803ab6998450c8d39d0c0c3nd<directivesynopsis location="mpm_common"><name>SendBufferSize</name>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive</directivesynopsis>
9cd774340b4867bf4803ab6998450c8d39d0c0c3nd<directivesynopsis location="mpm_common"><name>ServerLimit</name>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive</directivesynopsis>
9cd774340b4867bf4803ab6998450c8d39d0c0c3nd<directivesynopsis location="mpm_common"><name>StartServers</name>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive</directivesynopsis>
4c894c7d7c34890a8984b6cc1bcf6c19f15c4c0aniq<directivesynopsis location="mod_unixd"><name>User</name>
1a9d040bd97b9bacbcb5aead589523bf60572e04slive</directivesynopsis>
4c894c7d7c34890a8984b6cc1bcf6c19f15c4c0aniq<directivesynopsis location="mod_unixd"><name>Group</name>
9cd774340b4867bf4803ab6998450c8d39d0c0c3nd</directivesynopsis>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive<directivesynopsis>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive<name>MaxSpareServers</name>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive<description>Maximum number of idle child server processes</description>
3209c0009829fcf63b6213fb9c43d534f7906006slive<syntax>MaxSpareServers <var>number</var></syntax>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive<default>MaxSpareServers 10</default>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive<contextlist><context>server config</context></contextlist>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive<usage>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive <p>The <directive>MaxSpareServers</directive> directive sets the
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive desired maximum number of <em>idle</em> child server processes. An
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive idle process is one which is not handling a request. If there are
9cd774340b4867bf4803ab6998450c8d39d0c0c3nd more than <directive>MaxSpareServers</directive> idle, then the
9cd774340b4867bf4803ab6998450c8d39d0c0c3nd parent process will kill off the excess processes.</p>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive <p>Tuning of this parameter should only be necessary on very
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive busy sites. Setting this parameter to a large number is almost
f989aee1278b24f2b6e3a8e3b0935b590349de81jorton always a bad idea. If you are trying to set the value equal to or lower than
55478342807b8fbc71ba2af7444e3a06fad7ebf1rbowen <directive module="prefork">MinSpareServers</directive>, Apache HTTP Server
9cd774340b4867bf4803ab6998450c8d39d0c0c3nd will automatically adjust it to <directive
9cd774340b4867bf4803ab6998450c8d39d0c0c3nd >MinSpareServers</directive><code> + 1</code>.</p>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive</usage>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive<seealso><directive module="prefork">MinSpareServers</directive></seealso>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive<seealso><directive module="mpm_common">StartServers</directive></seealso>
5fe85d8662e07bb4e9dbe9c2d0274e90a3058135rbowen<seealso><directive module="mpm_common">MaxSpareThreads</directive></seealso>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive</directivesynopsis>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive<directivesynopsis>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive<name>MinSpareServers</name>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive<description>Minimum number of idle child server processes</description>
ea8a727ff298d2f5368b55b7ae8d87091ae106e7nd<syntax>MinSpareServers <var>number</var></syntax>
9cd774340b4867bf4803ab6998450c8d39d0c0c3nd<default>MinSpareServers 5</default>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive<contextlist><context>server config</context></contextlist>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive<usage>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive <p>The <directive>MinSpareServers</directive> directive sets the
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive desired minimum number of <em>idle</em> child server processes. An
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive idle process is one which is not handling a request. If there are
9cd774340b4867bf4803ab6998450c8d39d0c0c3nd fewer than <directive>MinSpareServers</directive> idle, then the parent
2bfb6b5514fae5aff3a3a56a15f3d5a545395c41igalic process creates new children: It will spawn one, wait a second, then spawn
2bfb6b5514fae5aff3a3a56a15f3d5a545395c41igalic two, wait a second, then spawn four, and it will
2bfb6b5514fae5aff3a3a56a15f3d5a545395c41igalic continue exponentially until it is spawning 32 children per second. It will
2bfb6b5514fae5aff3a3a56a15f3d5a545395c41igalic stop whenever it satisfies the <directive>MinSpareServers</directive>
2bfb6b5514fae5aff3a3a56a15f3d5a545395c41igalic setting.</p>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive <p>Tuning of this parameter should only be necessary on very
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive busy sites. Setting this parameter to a large number is almost
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive always a bad idea.</p>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive</usage>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive<seealso><directive module="prefork">MaxSpareServers</directive></seealso>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive<seealso><directive module="mpm_common">StartServers</directive></seealso>
5fe85d8662e07bb4e9dbe9c2d0274e90a3058135rbowen<seealso><directive module="mpm_common">MinSpareThreads</directive></seealso>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive</directivesynopsis>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive</modulesynopsis>
fc88db23cb4b205f1efea5f5d5ae916589db5a61slive