worker.xml revision bf0e7f6393e91c0a7c15cb0d889a4238c973dc2e
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding<!DOCTYPE modulesynopsis SYSTEM "/style/modulesynopsis.dtd">
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding<!-- $LastChangedRevision$ -->
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding Licensed to the Apache Software Foundation (ASF) under one or more
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding contributor license agreements. See the NOTICE file distributed with
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding this work for additional information regarding copyright ownership.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding The ASF licenses this file to You under the Apache License, Version 2.0
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding (the "License"); you may not use this file except in compliance with
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding the License. You may obtain a copy of the License at
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding Unless required by applicable law or agreed to in writing, software
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding distributed under the License is distributed on an "AS IS" BASIS,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding See the License for the specific language governing permissions and
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding limitations under the License.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding<description>Multi-Processing Module implementing a hybrid
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding multi-threaded multi-process web server</description>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding <p>This Multi-Processing Module (MPM) implements a hybrid
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding multi-process multi-threaded server. By using threads to serve
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding requests, it is able to serve a large number of requests with
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding fewer system resources than a process-based server. However, it
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding retains much of the stability of a process-based server by
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding keeping multiple processes available, each with many threads.</p>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding <p>The most important directives used to control this MPM are
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding <directive module="mpm_common">ThreadsPerChild</directive>, which
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding controls the number of threads deployed by each child process and
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding <directive module="mpm_common">MaxClients</directive>, which
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding controls the maximum total number of threads that may be
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding launched.</p>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding<seealso><a href="/bind.html">Setting which addresses and ports Apache
ec59f4e92f66631ee3266c0d416a01ac92bdf06cstoddard<section id="how-it-works"><title>How it Works</title>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding <p>A single control process (the parent) is responsible for launching
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding child processes. Each child process creates a fixed number of server
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding threads as specified in the <directive
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding module="mpm_common">ThreadsPerChild</directive> directive, as well
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding as a listener thread which listens for connections and passes them
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding to a server thread for processing when they arrive.</p>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding <p>Apache always tries to maintain a pool of <dfn>spare</dfn> or
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding idle server threads, which stand ready to serve incoming
4cff088e460b3832142e59c63b357f8cf4d77fa8ake requests. In this way, clients do not need to wait for a new
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding threads or processes to be created before their requests can be
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding served. The number of processes that will initially launched is
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding set by the <directive module="mpm_common">StartServers</directive>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding directive. During operation, Apache assesses the total number
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding of idle threads in all processes, and forks or kills processes to
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding keep this number within the boundaries specified by <directive
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding module="mpm_common">MinSpareThreads</directive> and <directive
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding module="mpm_common">MaxSpareThreads</directive>. Since this
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding process is very self-regulating, it is rarely necessary to modify
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding these directives from their default values. The maximum number of
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding clients that may be served simultaneously (i.e., the maximum total
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding number of threads in all processes) is determined by the
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding <directive module="mpm_common">MaxClients</directive> directive.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding The maximum number of active child processes is determined by
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding the <directive module="mpm_common">MaxClients</directive>
ec59f4e92f66631ee3266c0d416a01ac92bdf06cstoddard directive divided by the <directive module="mpm_common">
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding <p>Two directives set hard limits on the number of active child
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding processes and the number of server threads in a child process,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding and can only be changed by fully stopping the server and then
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding starting it again. <directive module="mpm_common">ServerLimit
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding </directive> is a hard limit on the number of active child
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding processes, and must be greater than or equal to the
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding <directive module="mpm_common">MaxClients</directive>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding directive divided by the <directive module="mpm_common">
4cff088e460b3832142e59c63b357f8cf4d77fa8ake ThreadsPerChild</directive> directive.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding <directive module="mpm_common">ThreadLimit</directive> is a hard
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding limit of the number of server threads, and must be greater than
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding or equal to the <directive
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding module="mpm_common">ThreadsPerChild</directive> directive.</p>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding <p>In addition to the set of active child processes, there may
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding be additional child processes which are terminating, but where at
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding least one server thread is still handling an existing client
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding connection. Up to <directive
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding module="mpm_common">MaxClients</directive> terminating processes
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding may be present, though the actual number can be expected to be
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding much smaller. This behavior can be avoided by disabling the
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding termination of individual child processes, which is achieved using
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding the following:</p>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding <li>set the value of <directive module="mpm_common">
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding <li>set the value of <directive module="mpm_common">
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding MaxSpareThreads</directive> to the same value as
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding <directive module="mpm_common">MaxClients</directive></li>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding <p>A typical configuration of the process-thread controls in
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding the <module>worker</module> MPM could look as follows:</p>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ServerLimit 16<br />