worker.html.en revision 87ffb6e33f3cbef3b9bb406cc2d27039fa336eaa
1662N/A<?xml version="1.0" encoding="ISO-8859-1"?>
1662N/A<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
1662N/A<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
1662N/A XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1662N/A This file is generated from xml source: DO NOT EDIT
1662N/A XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1662N/A -->
1662N/A<title>worker - Apache HTTP Server</title>
1662N/A<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
409N/A<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
1662N/A<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
1662N/A<link href="/images/favicon.ico" rel="shortcut icon" /></head>
1662N/A<body>
1662N/A<div id="page-header">
1662N/A<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p>
1662N/A<p class="apache">Apache HTTP Server Version 2.1</p>
1662N/A<img alt="" src="/images/feather.gif" /></div>
1662N/A<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="/images/left.gif" /></a></div>
1662N/A<div id="path">
409N/A<a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs-project/">Documentation</a> &gt; <a href="../">Version 2.1</a> &gt; <a href="./">Modules</a></div>
1662N/A<div id="page-content">
1662N/A<div id="preamble"><h1>Apache MPM worker</h1>
1662N/A<div class="toplang">
1662N/A<p><span>Available Languages: </span><a href="/de/mod/worker.html" hreflang="de" rel="alternate" title="Deutsch">&nbsp;de&nbsp;</a> |
1662N/A<a href="/en/mod/worker.html" title="English">&nbsp;en&nbsp;</a> |
1662N/A<a href="/ja/mod/worker.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a></p>
409N/A</div>
1662N/A<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Multi-Processing Module implementing a hybrid
1662N/A multi-threaded multi-process web server</td></tr>
1662N/A<tr><th><a href="module-dict.html#Status">Status:</a></th><td>MPM</td></tr>
1662N/A<tr><th><a href="module-dict.html#ModuleIdentifier">Module�Identifier:</a></th><td>mpm_worker_module</td></tr>
409N/A<tr><th><a href="module-dict.html#SourceFile">Source�File:</a></th><td>worker.c</td></tr></table>
1662N/A<h3>Summary</h3>
1662N/A
1662N/A <p>This Multi-Processing Module (MPM) implements a hybrid
1662N/A multi-process multi-threaded server. By using threads to serve
1662N/A requests, it is able to serve a large number of requests with
409N/A less system resources than a process-based server. Yet it
1662N/A retains much of the stability of a process-based server by
1662N/A keeping multiple processes available, each with many threads.</p>
1662N/A
409N/A <p>The most important directives used to control this MPM are
1662N/A <code class="directive"><a href="/mod/mpm_common.html#threadsperchild">ThreadsPerChild</a></code>, which
1662N/A controls the number of threads deployed by each child process and
1662N/A <code class="directive"><a href="/mod/mpm_common.html#maxclients">MaxClients</a></code>, which
1662N/A controls the maximum total number of threads that may be
1662N/A launched.</p>
1662N/A</div>
409N/A<div id="quickview"><h3 class="directives">Directives</h3>
1662N/A<ul id="toc">
1662N/A<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#acceptmutex">AcceptMutex</a></li>
1662N/A<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#coredumpdirectory">CoreDumpDirectory</a></li>
1662N/A<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#enableexceptionhook">EnableExceptionHook</a></li>
1662N/A<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#group">Group</a></li>
409N/A<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#listen">Listen</a></li>
1662N/A<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#listenbacklog">ListenBacklog</a></li>
1662N/A<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#lockfile">LockFile</a></li>
1662N/A<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#maxclients">MaxClients</a></li>
1662N/A<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#maxmemfree">MaxMemFree</a></li>
1662N/A<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#maxrequestsperchild">MaxRequestsPerChild</a></li>
409N/A<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#maxsparethreads">MaxSpareThreads</a></li>
1662N/A<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#minsparethreads">MinSpareThreads</a></li>
1662N/A<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#pidfile">PidFile</a></li>
1662N/A<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#scoreboardfile">ScoreBoardFile</a></li>
1662N/A<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#sendbuffersize">SendBufferSize</a></li>
1662N/A<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#serverlimit">ServerLimit</a></li>
1662N/A<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#startservers">StartServers</a></li>
1662N/A<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#threadlimit">ThreadLimit</a></li>
1662N/A<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#threadsperchild">ThreadsPerChild</a></li>
1662N/A<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#threadstacksize">ThreadStackSize</a></li>
409N/A<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#user">User</a></li>
1662N/A</ul>
1662N/A<h3>Topics</h3>
1662N/A<ul id="topics">
1662N/A<li><img alt="" src="/images/down.gif" /> <a href="#how-it-works">How it Works</a></li>
1662N/A</ul><h3>See also</h3>
1662N/A<ul class="seealso">
409N/A<li><a href="/bind.html">Setting which addresses and ports Apache
1662N/Auses</a></li>
1662N/A</ul></div>
1662N/A<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
1662N/A<div class="section">
1662N/A<h2><a name="how-it-works" id="how-it-works">How it Works</a></h2>
1662N/A <p>A single control process (the parent) is responsible for launching
1662N/A child processes. Each child process creates a fixed number of server
409N/A threads as specified in the <code class="directive"><a href="/mod/mpm_common.html#threadsperchild">ThreadsPerChild</a></code> directive, as well
1662N/A as a listener thread which listens for connections and passes them
1662N/A to a server thread for processing when they arrive.</p>
409N/A
1662N/A <p>Apache always tries to maintain a pool of <dfn>spare</dfn> or
1662N/A idle server threads, which stand ready to serve incoming
1662N/A requests. In this way, clients do not need to wait for a new
1662N/A threads or processes to be created before their requests can be
1662N/A served. The number of processes that will initially launched is
1662N/A set by the <code class="directive"><a href="/mod/mpm_common.html#startservers">StartServers</a></code>
409N/A directive. Then during operation, Apache assesses the total number
1662N/A of idle threads in all processes, and forks or kills processes to
1662N/A keep this number within the boundaries specified by <code class="directive"><a href="/mod/mpm_common.html#minsparethreads">MinSpareThreads</a></code> and <code class="directive"><a href="/mod/mpm_common.html#maxsparethreads">MaxSpareThreads</a></code>. Since this
1662N/A process is very self-regulating, it is rarely necessary to modify
1662N/A these directives from their default values. The maximum number of
409N/A clients that may be served simultaneously (i.e., the maximum total
1662N/A number of threads in all processes) is determined by the
1662N/A <code class="directive"><a href="/mod/mpm_common.html#maxclients">MaxClients</a></code> directive.
1662N/A The maximum number of active child processes is determined by
1662N/A the <code class="directive"><a href="/mod/mpm_common.html#maxclients">MaxClients</a></code>
1662N/A directive divided by the <code class="directive"><a href="/mod/mpm_common.html#&#10; threadsperchild">
1662N/A ThreadsPerChild</a></code> directive.</p>
1662N/A
1662N/A <p>Two directives set hard limits on the number of active child
1662N/A processes and the number of server threads in a child process,
1662N/A and can only be changed by fully stopping the server and then
1662N/A starting it again. <code class="directive"><a href="/mod/mpm_common.html#serverlimit&#10; ">ServerLimit
1662N/A </a></code> is a hard limit on the number of active child
1662N/A processes, and must be greater than or equal to the
1662N/A <code class="directive"><a href="/mod/mpm_common.html#maxclients">MaxClients</a></code>
1662N/A directive divided by the <code class="directive"><a href="/mod/mpm_common.html#&#10; threadsperchild">
1662N/A ThreadsPerChild</a></code> directive.
1662N/A <code class="directive"><a href="/mod/mpm_common.html#threadlimit">ThreadLimit</a></code> is a hard
1662N/A limit of the number of server threads, and must be greater than
1662N/A or equal to the <code class="directive"><a href="/mod/mpm_common.html#threadsperchild">ThreadsPerChild</a></code> directive. If
1662N/A non-default values are specified for these directives, they
1662N/A should appear before other <code class="module"><a href="/mod/worker.html">worker</a></code> directives.</p>
1662N/A
1662N/A <p>In addition to a the set of active child processes, there may
1662N/A be additional child processes which are terminating but where at
409N/A least one server thread is still handling an existing client
1662N/A connection. Up to <code class="directive"><a href="/mod/mpm_common.html#maxclient">MaxClient</a></code> terminating processes
1662N/A may be present, though the actual number can be expected to be
1662N/A much smaller. This behavior can be avoided by disabling the
1662N/A termination of individual child processes, which is achieved by
1662N/A the following:</p>
1662N/A
1662N/A <ul>
1662N/A <li>set the value of <code class="directive"><a href="/mod/mpm_common.html#&#10; maxrequestsperchild">
1662N/A MaxRequestsPerChild</a></code> to zero</li>
1662N/A
1662N/A <li>set the value of <code class="directive"><a href="/mod/mpm_common.html#&#10; maxsparethreads">
1662N/A MaxSpareThreads</a></code> to the same value as
409N/A <code class="directive"><a href="/mod/mpm_common.html#maxclients">MaxClients</a></code></li>
1662N/A </ul>
1662N/A
1662N/A <p>A typical configuration of the process-thread controls in
1662N/A the <code class="module"><a href="/mod/worker.html">worker</a></code> MPM could look as follows:</p>
1662N/A
1662N/A <div class="example"><p><code>
409N/A ServerLimit 16<br />
1662N/A StartServers 2<br />
1662N/A MaxClients 150<br />
1662N/A MinSpareThreads 25<br />
1662N/A MaxSpareThreads 75<br />
1662N/A ThreadsPerChild 25
409N/A </code></p></div>
1662N/A
1662N/A <p>While the parent process is usually started as <code>root</code>
1662N/A under Unix in order to bind to port 80, the child processes and threads
1662N/A are launched by Apache as a less-privileged user. The <code class="directive"><a href="/mod/mpm_common.html#user">User</a></code> and <code class="directive"><a href="/mod/mpm_common.html#group">Group</a></code> directives are used to set
1662N/A the privileges of the Apache child processes. The child processes
1662N/A must be able to read all the content that will be served, but
1662N/A should have as few privileges beyond that as possible. In
1662N/A addition, unless <a href="/suexec.html">suexec</a> is used,
1662N/A these directives also set the privileges which will be inherited
1662N/A by CGI scripts.</p>
409N/A
1662N/A <p><code class="directive"><a href="/mod/mpm_common.html#maxrequestsperchild">MaxRequestsPerChild</a></code>
1662N/A controls how frequently the server recycles processes by killing
1662N/A old ones and launching new ones.</p>
1662N/A</div>
1662N/A</div>
1662N/A<div class="bottomlang">
1662N/A<p><span>Available Languages: </span><a href="/de/mod/worker.html" hreflang="de" rel="alternate" title="Deutsch">&nbsp;de&nbsp;</a> |
1662N/A<a href="/en/mod/worker.html" title="English">&nbsp;en&nbsp;</a> |
1662N/A<a href="/ja/mod/worker.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a></p>
1662N/A</div><div id="footer">
1662N/A<p class="apache">Copyright 1999-2004 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
1662N/A<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p></div>
1662N/A</body></html>