worker.html.en revision e8d485701957d5c6de870111c112e168a894d49a
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<?xml version="1.0" encoding="ISO-8859-1"?>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann This file is generated from xml source: DO NOT EDIT
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann -->
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<title>worker - Apache HTTP Server</title>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<link href="/images/favicon.ico" rel="shortcut icon" /></head>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<body>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<div id="page-header">
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<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>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<p class="apache">Apache HTTP Server Version 2.1</p>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<img alt="" src="/images/feather.gif" /></div>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="/images/left.gif" /></a></div>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<div id="path">
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<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>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<div id="page-content">
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<div id="preamble"><h1>Apache MPM worker</h1>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Multi-Processing Module implementing a hybrid
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann multi-threaded multi-process web server</td></tr>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<tr><th><a href="module-dict.html#Status">Status:</a></th><td>MPM</td></tr>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<tr><th><a href="module-dict.html#ModuleIdentifier">Module�Identifier:</a></th><td>mpm_worker_module</td></tr>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<tr><th><a href="module-dict.html#SourceFile">Source�File:</a></th><td>worker.c</td></tr></table>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<h3>Summary</h3>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann <p>This Multi-Processing Module (MPM) implements a hybrid
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann multi-process multi-threaded server. By using threads to serve
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann requests, it is able to serve a large number of requests with
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann less system resources than a process-based server. Yet it
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann retains much of the stability of a process-based server by
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann keeping multiple processes available, each with many threads.</p>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann <p>The most important directives used to control this MPM are
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann <code class="directive"><a href="/mod/mpm_common.html#threadsperchild">ThreadsPerChild</a></code>, which
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann controls the number of threads deployed by each child process and
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann <code class="directive"><a href="/mod/mpm_common.html#maxclients">MaxClients</a></code>, which
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann controls the maximum total number of threads that may be
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann launched.</p>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann</div>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<div id="quickview"><h3 class="directives">Directives</h3>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<ul id="toc">
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#acceptmutex">AcceptMutex</a></li>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#coredumpdirectory">CoreDumpDirectory</a></li>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#group">Group</a></li>
5476ad087c0f2d45ab0dab1bab9ef3e9d70418bcMarcel Holtmann<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#listen">Listen</a></li>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#listenbacklog">ListenBacklog</a></li>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#lockfile">LockFile</a></li>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#maxclients">MaxClients</a></li>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#maxmemfree">MaxMemFree</a></li>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#maxrequestsperchild">MaxRequestsPerChild</a></li>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#maxsparethreads">MaxSpareThreads</a></li>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#minsparethreads">MinSpareThreads</a></li>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#pidfile">PidFile</a></li>
5476ad087c0f2d45ab0dab1bab9ef3e9d70418bcMarcel Holtmann<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#scoreboardfile">ScoreBoardFile</a></li>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#sendbuffersize">SendBufferSize</a></li>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#serverlimit">ServerLimit</a></li>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#startservers">StartServers</a></li>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#threadlimit">ThreadLimit</a></li>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#threadsperchild">ThreadsPerChild</a></li>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<li><img alt="" src="/images/right.gif" /> <a href="mpm_common.html#user">User</a></li>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann</ul>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<h3>Topics</h3>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<ul id="topics">
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<li><img alt="" src="/images/down.gif" /> <a href="#how-it-works">How it Works</a></li>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann</ul><h3>See also</h3>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<ul class="seealso">
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<li><a href="/bind.html">Setting which addresses and ports Apache
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannuses</a></li>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann</ul></div>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<div class="section">
5476ad087c0f2d45ab0dab1bab9ef3e9d70418bcMarcel Holtmann<h2><a name="how-it-works" id="how-it-works">How it Works</a></h2>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann <p>Each process has a fixed
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann number of threads. The server adjusts to handle load by
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann increasing or decreasing the number of processes.</p>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann <p>A single control process is responsible for launching child
5476ad087c0f2d45ab0dab1bab9ef3e9d70418bcMarcel Holtmann processes. Each child process creates a fixed number of threads as
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann specified in the <code class="directive"><a href="/mod/mpm_common.html#threadsperchild">ThreadsPerChild</a></code> directive. The
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann individual threads then listen for connections and serve them when
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann they arrive.</p>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann <p>Apache always tries to maintain a pool of <dfn>spare</dfn> or
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann idle server threads, which stand ready to serve incoming
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann requests. In this way, clients do not need to wait for a new
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann threads or processes to be created before their requests can be
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann served. The number of processes that will initially launched is
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann set by the <code class="directive"><a href="/mod/mpm_common.html#startservers">StartServers</a></code>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann directive. Then during operation, Apache assesses the total number
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann of idle threads in all processes, and forks or kills processes to
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann 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
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann process is very self-regulating, it is rarely necessary to modify
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann these directives from their default values. The maximum number of
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann clients that may be served simultaneously (i.e., the maximum total
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann number of threads in all processes) is determined by the
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann <code class="directive"><a href="/mod/mpm_common.html#maxclients">MaxClients</a></code> directive,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann while the maximum number of processes that can be launched is set
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann by the <code class="directive"><a href="/mod/mpm_common.html#serverlimit">ServerLimit</a></code>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann directive. <code class="directive"><a href="/mod/mpm_common.html#serverlimit">ServerLimit</a></code>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann multiplied by <code class="directive"><a href="/mod/mpm_common.html#threadsperchild">ThreadsPerChild</a></code> must be greater
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann than or equal to <code class="directive"><a href="/mod/mpm_common.html#maxclients">MaxClients</a></code></p>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann <p>A typical configuration of the process-thread controls in
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann the <code class="module"><a href="/mod/worker.html">worker</a></code> MPM could look as follows:</p>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann <div class="example"><p><code>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann StartServers 2<br />
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann MaxClients 150<br />
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann MinSpareThreads 25<br />
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann MaxSpareThreads 75<br />
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ThreadsPerChild 25<br />
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ServerLimit 16
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann </code></p></div>
7cfa80f07e94c3e48703d145ef03a73dd6e7b983Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann <p>While the parent process is usually started as <code>root</code>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann under Unix in order to bind to port 80, the child processes and threads
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann 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
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann the privileges of the Apache child processes. The child processes
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann must be able to read all the content that will be served, but
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann should have as few privileges beyond that as possible. In
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann addition, unless <a href="/suexec.html">suexec</a> is used,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann these directives also set the privileges which will be inherited
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann by CGI scripts.</p>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann <p><code class="directive"><a href="/mod/mpm_common.html#maxrequestsperchild">MaxRequestsPerChild</a></code>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann controls how frequently the server recycles processes by killing
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann old ones and launching new ones.</p>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann</div>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann</div>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<div id="footer">
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<p class="apache">Maintained by the <a href="http://httpd.apache.org/docs-project/">Apache HTTP Server Documentation Project</a></p>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann<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>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann</body></html>