worker.xml revision f8396ed8364b56ec8adeaa49cac35a929758a29e
6ae232055d4d8a97267517c5e50074c2c819941and<!DOCTYPE modulesynopsis SYSTEM "/style/modulesynopsis.dtd">
6ae232055d4d8a97267517c5e50074c2c819941and<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
6ae232055d4d8a97267517c5e50074c2c819941and<modulesynopsis>
6ae232055d4d8a97267517c5e50074c2c819941and<description>Multi-Processing Module implementing a hybrid
6ae232055d4d8a97267517c5e50074c2c819941and multi-threaded multi-process web server</description>
6ae232055d4d8a97267517c5e50074c2c819941and <p>This Multi-Processing Module (MPM) implements a hybrid
6ae232055d4d8a97267517c5e50074c2c819941and multi-process multi-threaded server. By using threads to serve
6ae232055d4d8a97267517c5e50074c2c819941and requests, it is able to serve a large number of requests with
6ae232055d4d8a97267517c5e50074c2c819941and less system resources than a process-based server. Yet it
6ae232055d4d8a97267517c5e50074c2c819941and retains much of the stability of a process-based server by
6ae232055d4d8a97267517c5e50074c2c819941and keeping multiple processes available, each with many threads.</p>
6ae232055d4d8a97267517c5e50074c2c819941and <p>The most important directives used to control this MPM are
6ae232055d4d8a97267517c5e50074c2c819941and <directive module="mpm_common">ThreadsPerChild</directive>, which
6ae232055d4d8a97267517c5e50074c2c819941and controls the number of threads deployed by each child process and
6ae232055d4d8a97267517c5e50074c2c819941and <directive module="mpm_common">MaxClients</directive>, which
6ae232055d4d8a97267517c5e50074c2c819941and controls the maximum total number of threads that may be
4b3a8afbfcea8b265d179a122bf40dfedd1ce280takashi launched.</p>
6ae232055d4d8a97267517c5e50074c2c819941and <p>Each process has a fixed
6ae232055d4d8a97267517c5e50074c2c819941and number of threads. The server adjusts to handle load by
6ae232055d4d8a97267517c5e50074c2c819941and increasing or decreasing the number of processes.</p>
6ae232055d4d8a97267517c5e50074c2c819941and <p>A single control process is responsible for launching child
6ae232055d4d8a97267517c5e50074c2c819941and processes. Each child process creates a fixed number of threads as
6ae232055d4d8a97267517c5e50074c2c819941and specified in the <directive
6ae232055d4d8a97267517c5e50074c2c819941and module="mpm_common">ThreadsPerChild</directive> directive. The
6ae232055d4d8a97267517c5e50074c2c819941and individual threads then listen for connections and serve them when
6ae232055d4d8a97267517c5e50074c2c819941and they arrive.</p>
6ae232055d4d8a97267517c5e50074c2c819941and <p>Apache always tries to maintain a pool of <em>spare</em> or
6ae232055d4d8a97267517c5e50074c2c819941and idle server threads, which stand ready to serve incoming
6ae232055d4d8a97267517c5e50074c2c819941and requests. In this way, clients do not need to wait for a new
6ae232055d4d8a97267517c5e50074c2c819941and threads or processes to be created before their requests can be
6ae232055d4d8a97267517c5e50074c2c819941and served. The number of processes that will initially launched is
6ae232055d4d8a97267517c5e50074c2c819941and set by the <directive module="mpm_common">StartServers</directive>
6ae232055d4d8a97267517c5e50074c2c819941and directive. Then during operation, Apache assesses the total number
6ae232055d4d8a97267517c5e50074c2c819941and of idle threads in all processes, and forks or kills processes to
6ae232055d4d8a97267517c5e50074c2c819941and keep this number within the boundaries specified by <directive
6ae232055d4d8a97267517c5e50074c2c819941and module="mpm_common">MinSpareThreads</directive> and <directive
6ae232055d4d8a97267517c5e50074c2c819941and module="mpm_common">MaxSpareThreads</directive>. Since this
6ae232055d4d8a97267517c5e50074c2c819941and process is very self-regulating, it is rarely necessary to modify
070897b4d34cbd17fd2846289189f2a9891f9c84takashi these directives from their default values. The maximum number of
070897b4d34cbd17fd2846289189f2a9891f9c84takashi clients that may be served simultaneously (i.e., the maximum total
6ae232055d4d8a97267517c5e50074c2c819941and number of threads in all processes) is determined by the
6ae232055d4d8a97267517c5e50074c2c819941and <directive module="mpm_common">MaxClients</directive> directive,
6ae232055d4d8a97267517c5e50074c2c819941and while the maximum number of processes that can be launched is set
6ae232055d4d8a97267517c5e50074c2c819941and by the <directive module="mpm_common">ServerLimit</directive>
6ae232055d4d8a97267517c5e50074c2c819941and directive. <directive module="mpm_common">ServerLimit</directive>
6ae232055d4d8a97267517c5e50074c2c819941and multiplied by <directive
6ae232055d4d8a97267517c5e50074c2c819941and module="mpm_common">ThreadsPerChild</directive> must be greater
6ae232055d4d8a97267517c5e50074c2c819941and than or equal to <directive
6ae232055d4d8a97267517c5e50074c2c819941and <p>A typical configuration of the process-thread controls in
6ae232055d4d8a97267517c5e50074c2c819941and the <module>worker</module> MPM could look as follows:</p>
6ae232055d4d8a97267517c5e50074c2c819941andMaxClients 150
6ae232055d4d8a97267517c5e50074c2c819941andMinSpareThreads 25
6ae232055d4d8a97267517c5e50074c2c819941andMaxSpareThreads 75
6ae232055d4d8a97267517c5e50074c2c819941andThreadsPerChild 25
6ae232055d4d8a97267517c5e50074c2c819941and <p>While the parent process is usually started as root under Unix
6ae232055d4d8a97267517c5e50074c2c819941and in order to bind to port 80, the child processes and threads are
6ae232055d4d8a97267517c5e50074c2c819941and launched by Apache as a less-privileged user. The <directive
6ae232055d4d8a97267517c5e50074c2c819941and module="mpm_common">Group</directive> directives are used to set
6ae232055d4d8a97267517c5e50074c2c819941and the privileges of the Apache child processes. The child processes
6ae232055d4d8a97267517c5e50074c2c819941and must be able to read all the content that will be served, but
6ae232055d4d8a97267517c5e50074c2c819941and should have as few privileges beyond that as possible. In
6ae232055d4d8a97267517c5e50074c2c819941and addition, unless <a href="/suexec.html">suexec</a> is used,
6ae232055d4d8a97267517c5e50074c2c819941and these directives also set the privileges which will be inherited
6ae232055d4d8a97267517c5e50074c2c819941and by CGI scripts.</p>
6ae232055d4d8a97267517c5e50074c2c819941and <p><directive module="mpm_common">MaxRequestsPerChild</directive>
6ae232055d4d8a97267517c5e50074c2c819941and controls how frequently the server recycles processes by killing
6ae232055d4d8a97267517c5e50074c2c819941and old ones and launching new ones.</p>
6ae232055d4d8a97267517c5e50074c2c819941and<directivesynopsis location="mpm_common"><name>CoreDumpDirectory</name>
6ae232055d4d8a97267517c5e50074c2c819941and</directivesynopsis>
6ae232055d4d8a97267517c5e50074c2c819941and<directivesynopsis location="mpm_common"><name>Group</name>
6ae232055d4d8a97267517c5e50074c2c819941and</directivesynopsis>
6ae232055d4d8a97267517c5e50074c2c819941and<directivesynopsis location="mpm_common"><name>PidFile</name>
6ae232055d4d8a97267517c5e50074c2c819941and</directivesynopsis>
6ae232055d4d8a97267517c5e50074c2c819941and<directivesynopsis location="mpm_common"><name>Listen</name>
6ae232055d4d8a97267517c5e50074c2c819941and</directivesynopsis>
6ae232055d4d8a97267517c5e50074c2c819941and<directivesynopsis location="mpm_common"><name>ListenBacklog</name>
6ae232055d4d8a97267517c5e50074c2c819941and</directivesynopsis>
6ae232055d4d8a97267517c5e50074c2c819941and<directivesynopsis location="mpm_common"><name>LockFile</name>
6ae232055d4d8a97267517c5e50074c2c819941and</directivesynopsis>
6ae232055d4d8a97267517c5e50074c2c819941and<directivesynopsis location="mpm_common"><name>MaxClients</name>
6ae232055d4d8a97267517c5e50074c2c819941and</directivesynopsis>
6ae232055d4d8a97267517c5e50074c2c819941and<directivesynopsis location="mpm_common"><name>MaxRequestsPerChild</name>
6ae232055d4d8a97267517c5e50074c2c819941and</directivesynopsis>
6ae232055d4d8a97267517c5e50074c2c819941and<directivesynopsis location="mpm_common"><name>MaxSpareThreads</name>
6ae232055d4d8a97267517c5e50074c2c819941and</directivesynopsis>
6ae232055d4d8a97267517c5e50074c2c819941and<directivesynopsis location="mpm_common"><name>MinSpareThreads</name>
6ae232055d4d8a97267517c5e50074c2c819941and</directivesynopsis>
6ae232055d4d8a97267517c5e50074c2c819941and<directivesynopsis location="mpm_common"><name>ScoreBoardFile</name>
6ae232055d4d8a97267517c5e50074c2c819941and</directivesynopsis>
6ae232055d4d8a97267517c5e50074c2c819941and<directivesynopsis location="mpm_common"><name>SendBufferSize</name>
6ae232055d4d8a97267517c5e50074c2c819941and</directivesynopsis>
6ae232055d4d8a97267517c5e50074c2c819941and<directivesynopsis location="mpm_common"><name>ServerLimit</name>
6ae232055d4d8a97267517c5e50074c2c819941and</directivesynopsis>
6ae232055d4d8a97267517c5e50074c2c819941and<directivesynopsis location="mpm_common"><name>StartServers</name>
6ae232055d4d8a97267517c5e50074c2c819941and</directivesynopsis>
6ae232055d4d8a97267517c5e50074c2c819941and<directivesynopsis location="mpm_common"><name>ThreadLimit</name>
6ae232055d4d8a97267517c5e50074c2c819941and</directivesynopsis>
6ae232055d4d8a97267517c5e50074c2c819941and<directivesynopsis location="mpm_common"><name>ThreadsPerChild</name>
6ae232055d4d8a97267517c5e50074c2c819941and</directivesynopsis>
6ae232055d4d8a97267517c5e50074c2c819941and<directivesynopsis location="mpm_common"><name>User</name>
6ae232055d4d8a97267517c5e50074c2c819941and</directivesynopsis>
4b3a8afbfcea8b265d179a122bf40dfedd1ce280takashi</modulesynopsis>