event.xml revision 27b9f42e4e894c2a8ed786f87d0fc134a50fcdd8
97a9a944b5887e91042b019776c41d5dd74557aferikabele<?xml version="1.0"?>
97a9a944b5887e91042b019776c41d5dd74557aferikabele<!DOCTYPE modulesynopsis SYSTEM "/style/modulesynopsis.dtd">
97a9a944b5887e91042b019776c41d5dd74557aferikabele<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive<!-- $LastChangedRevision$ -->
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive<!--
b686b6a420bde7f78c416b90be11db94cb789979nd Licensed to the Apache Software Foundation (ASF) under one or more
b686b6a420bde7f78c416b90be11db94cb789979nd contributor license agreements. See the NOTICE file distributed with
b686b6a420bde7f78c416b90be11db94cb789979nd this work for additional information regarding copyright ownership.
b686b6a420bde7f78c416b90be11db94cb789979nd The ASF licenses this file to You under the Apache License, Version 2.0
b686b6a420bde7f78c416b90be11db94cb789979nd (the "License"); you may not use this file except in compliance with
b686b6a420bde7f78c416b90be11db94cb789979nd the License. You may obtain a copy of the License at
b686b6a420bde7f78c416b90be11db94cb789979nd
b686b6a420bde7f78c416b90be11db94cb789979nd http://www.apache.org/licenses/LICENSE-2.0
b686b6a420bde7f78c416b90be11db94cb789979nd
b686b6a420bde7f78c416b90be11db94cb789979nd Unless required by applicable law or agreed to in writing, software
b686b6a420bde7f78c416b90be11db94cb789979nd distributed under the License is distributed on an "AS IS" BASIS,
b686b6a420bde7f78c416b90be11db94cb789979nd WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd See the License for the specific language governing permissions and
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd limitations under the License.
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd-->
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd
b05ab3ff5ab54aa22610b13d56eaba6ddfc3db60nd<modulesynopsis metafile="event.xml.meta">
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd<name>event</name>
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd<description>A variant of the <module>worker</module> MPM with the goal
3b3b7fc78d1f5bfc2769903375050048ff41ff26ndof consuming threads only for connections with active processing</description>
b686b6a420bde7f78c416b90be11db94cb789979nd<status>MPM</status>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<sourcefile>event.c</sourcefile>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<identifier>mpm_event_module</identifier>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<summary>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>The <module>event</module> Multi-Processing Module (MPM) is
06ba4a61654b3763ad65f52283832ebf058fdf1cslive designed to allow more requests to be served simultaneously by
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd passing off some processing work to supporting threads, freeing up
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd the main threads to work on new requests. It is based on the
5b10fd3977e6dfff19afe770e612e276962f7950nd <module>worker</module> MPM, which implements a hybrid
5b10fd3977e6dfff19afe770e612e276962f7950nd multi-process multi-threaded server. Run-time configuration
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd directives are identical to those provided by
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd <module>worker</module>.</p>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd <p>To use the <module>event</module> MPM, add
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd <code>--with-mpm=event</code> to the <program>configure</program>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd script's arguments when building the <program>httpd</program>.</p>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd
5b10fd3977e6dfff19afe770e612e276962f7950nd</summary>
5b10fd3977e6dfff19afe770e612e276962f7950nd
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd<seealso><a href="worker.html">The worker MPM</a></seealso>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd
2aff288113d772cedca6add888eb643afffe9fb1nd<section id="how-it-works"><title>How it Works</title>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd <p>This MPM tries to fix the 'keep alive problem' in HTTP. After a client
2aff288113d772cedca6add888eb643afffe9fb1nd completes the first request, the client can keep the connection
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd open, and send further requests using the same socket. This can
7fa75a06a4fee19e995c069ee00310455d1452e1pquerna save significant overhead in creating TCP connections. However,
7fa75a06a4fee19e995c069ee00310455d1452e1pquerna Apache HTTP Server traditionally keeps an entire child process/thread waiting
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd for data from the client, which brings its own disadvantages. To
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd solve this problem, this MPM uses a dedicated thread to handle both
2aff288113d772cedca6add888eb643afffe9fb1nd the Listening sockets, all sockets that are in a Keep Alive state,
2aff288113d772cedca6add888eb643afffe9fb1nd and sockets where the handler and protocol filters have done their work
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd and the only remaining thing to do is send the data to the client. The
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd status page of <module>mod_status</module> shows how many connections are
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd in the mentioned states.</p>
2aff288113d772cedca6add888eb643afffe9fb1nd
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd <p>The improved connection handling does not yet work for certain
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd connection filters, in particular SSL. For SSL connections, this MPM will
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd fall back to the behaviour of the <module>worker</module> MPM and
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd reserve one worker thread per connection.</p>
2aff288113d772cedca6add888eb643afffe9fb1nd
2aff288113d772cedca6add888eb643afffe9fb1nd <p>The MPM assumes that the underlying <code>apr_pollset</code>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd implementation is reasonably threadsafe. This enables the MPM to
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd avoid excessive high level locking, or having to wake up the listener
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd thread in order to send it a keep-alive socket. This is currently
db99fa79ac42b9cc42b63386eb289aecb0f3cb9cnd only compatible with KQueue and EPoll.</p>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd
2aff288113d772cedca6add888eb643afffe9fb1nd</section>
2aff288113d772cedca6add888eb643afffe9fb1nd<section id="requirements"><title>Requirements</title>
2aff288113d772cedca6add888eb643afffe9fb1nd <p>This MPM depends on <glossary>APR</glossary>'s atomic
2aff288113d772cedca6add888eb643afffe9fb1nd compare-and-swap operations for thread synchronization. If you are
2aff288113d772cedca6add888eb643afffe9fb1nd compiling for an x86 target and you don't need to support 386s, or
2aff288113d772cedca6add888eb643afffe9fb1nd you are compiling for a SPARC and you don't need to run on
2aff288113d772cedca6add888eb643afffe9fb1nd pre-UltraSPARC chips, add
2aff288113d772cedca6add888eb643afffe9fb1nd <code>--enable-nonportable-atomics=yes</code> to the
bc525661d031758c0a4e771543372b4869ca86aand <program>configure</program> script's arguments. This will cause
bc525661d031758c0a4e771543372b4869ca86aand APR to implement atomic operations using efficient opcodes not
2aff288113d772cedca6add888eb643afffe9fb1nd available in older CPUs.</p>
2aff288113d772cedca6add888eb643afffe9fb1nd
2aff288113d772cedca6add888eb643afffe9fb1nd <p>This MPM does not perform well on older platforms which lack good
aa0b2780958e9b1467c9d0153a05738e399811a5nd threading, but the requirement for EPoll or KQueue makes this
2aff288113d772cedca6add888eb643afffe9fb1nd moot.</p>
42af92a661a06b3cebc88d585aad75064a309d51nd
42af92a661a06b3cebc88d585aad75064a309d51nd <ul>
2aff288113d772cedca6add888eb643afffe9fb1nd
aa0b2780958e9b1467c9d0153a05738e399811a5nd <li>To use this MPM on FreeBSD, FreeBSD 5.3 or higher is recommended.
2aff288113d772cedca6add888eb643afffe9fb1nd However, it is possible to run this MPM on FreeBSD 5.2.1, if you
2aff288113d772cedca6add888eb643afffe9fb1nd use <code>libkse</code> (see <code>man libmap.conf</code>).</li>
2aff288113d772cedca6add888eb643afffe9fb1nd
64c02f1310b7747423957823ee09fb3608430f89nd <li>For NetBSD, at least version 2.0 is recommended.</li>
aa0b2780958e9b1467c9d0153a05738e399811a5nd
2aff288113d772cedca6add888eb643afffe9fb1nd <li>For Linux, a 2.6 kernel is recommended. It is also necessary to
2aff288113d772cedca6add888eb643afffe9fb1nd ensure that your version of <code>glibc</code> has been compiled
2aff288113d772cedca6add888eb643afffe9fb1nd with support for EPoll.</li>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd
2aff288113d772cedca6add888eb643afffe9fb1nd </ul>
2aff288113d772cedca6add888eb643afffe9fb1nd</section>
2aff288113d772cedca6add888eb643afffe9fb1nd
2aff288113d772cedca6add888eb643afffe9fb1nd<directivesynopsis location="mpm_common"><name>CoreDumpDirectory</name>
2aff288113d772cedca6add888eb643afffe9fb1nd</directivesynopsis>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd<directivesynopsis location="mpm_common"><name>EnableExceptionHook</name>
2aff288113d772cedca6add888eb643afffe9fb1nd</directivesynopsis>
e67fa8d3f161e595dd448fc24a591ee17ae59131nd<directivesynopsis location="mod_unixd"><name>Group</name>
05ede5110427cb9dc071cc671d5aaba5d3b88c79nd</directivesynopsis>
e8b603fa9ccf7b17b11b42df6d8916fd97c2331dnd<directivesynopsis location="mpm_common"><name>Listen</name>
bf94bedcb62d7f0b926f4286069def5ee6b07b60nd</directivesynopsis>
bf94bedcb62d7f0b926f4286069def5ee6b07b60nd<directivesynopsis location="mpm_common"><name>ListenBacklog</name>
2aff288113d772cedca6add888eb643afffe9fb1nd</directivesynopsis>
2aff288113d772cedca6add888eb643afffe9fb1nd<directivesynopsis location="mpm_common"><name>SendBufferSize</name>
bbcbf978a3074512c627c797fedcb30eeab7b39dslive</directivesynopsis>
ee5db395bc3723609919edfa96af387eea37c491jim<directivesynopsis location="mpm_common"><name>MaxRequestWorkers</name>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd</directivesynopsis>
2aff288113d772cedca6add888eb643afffe9fb1nd<directivesynopsis location="mpm_common"><name>MaxMemFree</name>
e55e60efce8a3e2139132c1d6ad9f6f0d2976614nd</directivesynopsis>
e55e60efce8a3e2139132c1d6ad9f6f0d2976614nd<directivesynopsis location="mpm_common"><name>MaxConnectionsPerChild</name>
2aff288113d772cedca6add888eb643afffe9fb1nd</directivesynopsis>
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive<directivesynopsis location="mpm_common"><name>MaxSpareThreads</name>
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive</directivesynopsis>
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive<directivesynopsis location="mpm_common"><name>MinSpareThreads</name>
75585bd48fe0f30483dba4762e61edf39ea3e0f6nd</directivesynopsis>
75585bd48fe0f30483dba4762e61edf39ea3e0f6nd<directivesynopsis location="mpm_common"><name>PidFile</name>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd</directivesynopsis>
03a4ff9ac4c9b8009249010e7c53bb86ff05915and<directivesynopsis location="mpm_common"><name>ScoreBoardFile</name>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd</directivesynopsis>
3b58542e01ec69422f3086db5825a12fc77b726end<directivesynopsis location="mpm_common"><name>ServerLimit</name>
a0d937b340692a3578f1d2f2535890c520c4bf0cnd</directivesynopsis>
7d15331eeb5429d7148d13d6fd914a641bf1c000pquerna<directivesynopsis location="mpm_common"><name>StartServers</name>
2aff288113d772cedca6add888eb643afffe9fb1nd</directivesynopsis>
2aff288113d772cedca6add888eb643afffe9fb1nd<directivesynopsis location="mpm_common"><name>ThreadLimit</name>
2aff288113d772cedca6add888eb643afffe9fb1nd</directivesynopsis>
2aff288113d772cedca6add888eb643afffe9fb1nd<directivesynopsis location="mpm_common"><name>ThreadsPerChild</name>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd</directivesynopsis>
08842292d2f1550b40ae73e0dafc7641c5955c82nd<directivesynopsis location="mpm_common"><name>ThreadStackSize</name>
2aff288113d772cedca6add888eb643afffe9fb1nd</directivesynopsis>
d2b809e5d72658bff23819d8b77f20e4939af541nd<directivesynopsis location="mod_unixd"><name>User</name>
2aff288113d772cedca6add888eb643afffe9fb1nd</directivesynopsis>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd
2aff288113d772cedca6add888eb643afffe9fb1nd<directivesynopsis>
2aff288113d772cedca6add888eb643afffe9fb1nd<name>AsyncRequestWorkerFactor</name>
2aff288113d772cedca6add888eb643afffe9fb1nd<description>Limit concurrent connections per process</description>
2aff288113d772cedca6add888eb643afffe9fb1nd<syntax>AsyncRequestWorkerFactor <var>factor</var></syntax>
2aff288113d772cedca6add888eb643afffe9fb1nd<default>2</default>
2aff288113d772cedca6add888eb643afffe9fb1nd<contextlist><context>server config</context> </contextlist>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd<compatibility>Available in version 2.3.13 and later</compatibility>
c023f60e35022146373e40249f0c8c8d623b6fcfnd
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd<usage>
a43bfa789f4e52dde53ae8e53fa0427b5c1cf977nd <p>The event MPM handles some connections in an asynchronous way, where
a43bfa789f4e52dde53ae8e53fa0427b5c1cf977nd request worker threads are only allocated for short periods of time as
101bf3584c853027d9e51df6edfff5ff70c80238jim needed, and other (mostly SSL) connections with one request worker thread
73ba54c33b4fcad0e13005e10ea8648c9fe4265bnd reserved per connection. This can lead to situations where all workers are
73ba54c33b4fcad0e13005e10ea8648c9fe4265bnd tied up and no worker thread is available to handle new work on established
73ba54c33b4fcad0e13005e10ea8648c9fe4265bnd async connections.</p>
73ba54c33b4fcad0e13005e10ea8648c9fe4265bnd
73ba54c33b4fcad0e13005e10ea8648c9fe4265bnd <p>To mitigate this problem, the event MPM does two things: Firstly, it
73ba54c33b4fcad0e13005e10ea8648c9fe4265bnd limits the number of connections accepted per process, depending on the
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd number of idle request workers. Secondly, if all workers are busy, it will
2aff288113d772cedca6add888eb643afffe9fb1nd close connections in keep-alive state even if the keep-alive timeout has
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd not expired. This allows the respective clients to reconnect to a
2aff288113d772cedca6add888eb643afffe9fb1nd different process which may still have worker threads available.</p>
2aff288113d772cedca6add888eb643afffe9fb1nd
2aff288113d772cedca6add888eb643afffe9fb1nd <p>This directive can be used to fine-tune the per-process connection
2aff288113d772cedca6add888eb643afffe9fb1nd limit. A process will only accept new connections if the current number of
2aff288113d772cedca6add888eb643afffe9fb1nd connections is lower than:</p>
2aff288113d772cedca6add888eb643afffe9fb1nd
2aff288113d772cedca6add888eb643afffe9fb1nd <p class="indent"><strong>
2aff288113d772cedca6add888eb643afffe9fb1nd <directive module="mpm_common">ThreadsPerChild</directive> +
2aff288113d772cedca6add888eb643afffe9fb1nd (<directive>AsyncRequestWorkerFactor</directive> *
2aff288113d772cedca6add888eb643afffe9fb1nd <var>number of idle workers</var>)
2aff288113d772cedca6add888eb643afffe9fb1nd </strong></p>
2aff288113d772cedca6add888eb643afffe9fb1nd
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd <p>This means the absolute maximum numbers of concurrent connections is:</p>
2aff288113d772cedca6add888eb643afffe9fb1nd
2aff288113d772cedca6add888eb643afffe9fb1nd <p class="indent"><strong>
2aff288113d772cedca6add888eb643afffe9fb1nd (<directive>AsyncRequestWorkerFactor</directive> + 1) *
2aff288113d772cedca6add888eb643afffe9fb1nd <directive module="mpm_common">MaxRequestWorkers</directive>
2aff288113d772cedca6add888eb643afffe9fb1nd </strong></p>
03c25fb6f628ac81f2ecb637d1e7502dcee783f3nd
03c25fb6f628ac81f2ecb637d1e7502dcee783f3nd <p><directive module="mpm_common">MaxRequestWorkers</directive> was called
2aff288113d772cedca6add888eb643afffe9fb1nd <directive>MaxClients</directive> prior to version 2.3.13. The above value
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd shows that the old name did not accurately describe its meaning for the event MPM.</p>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd <p><directive>AsyncRequestWorkerFactor</directive> can take non-integer
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd arguments, e.g "1.5".</p>
b05ab3ff5ab54aa22610b13d56eaba6ddfc3db60nd
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd</usage>
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd</directivesynopsis>
b95ae799514ad86a15610ad75808d7065e9847c9kess
b686b6a420bde7f78c416b90be11db94cb789979nd</modulesynopsis>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd