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