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
27b9f42e4e894c2a8ed786f87d0fc134a50fcdd8humbedooh save significant overhead in creating TCP connections. However,
381b101317d64df9ce37f788d903a999f9f26ca7rbowen 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
188a5ef97e793cb79096d1297a37747b1de03457sf the Listening sockets, all sockets that are in a Keep Alive state,
188a5ef97e793cb79096d1297a37747b1de03457sf and sockets where the handler and protocol filters have done their work
188a5ef97e793cb79096d1297a37747b1de03457sf and the only remaining thing to do is send the data to the client. The
188a5ef97e793cb79096d1297a37747b1de03457sf status page of <module>mod_status</module> shows how many connections are
188a5ef97e793cb79096d1297a37747b1de03457sf in the mentioned states.</p>
188a5ef97e793cb79096d1297a37747b1de03457sf
35e26fe7e0920b607afc63a645c846633f0e6889minfrin <p>The improved connection handling may not work for certain connection
35e26fe7e0920b607afc63a645c846633f0e6889minfrin filters that have declared themselves as incompatible with event. In these
35e26fe7e0920b607afc63a645c846633f0e6889minfrin cases, this MPM will fall back to the behaviour of the
35e26fe7e0920b607afc63a645c846633f0e6889minfrin <module>worker</module> MPM and reserve one worker thread per connection.
35e26fe7e0920b607afc63a645c846633f0e6889minfrin All modules shipped with the server are compatible with the event MPM.</p>
57758b7ebacbd303cb1c004dd67dd8e5cc1055dbslive
e06a6bccd7ccb44e34fe2de158e0450393f1683bsf <p>A similar restriction is currently present for requests involving an
e06a6bccd7ccb44e34fe2de158e0450393f1683bsf output filter that needs to read and/or modify the whole response body,
e06a6bccd7ccb44e34fe2de158e0450393f1683bsf like for example mod_ssl, mod_deflate, or mod_include. If the
e06a6bccd7ccb44e34fe2de158e0450393f1683bsf connection to the client blocks while the filter is processing the
e06a6bccd7ccb44e34fe2de158e0450393f1683bsf data, and the amount of data produced by the filter is too big to be
e06a6bccd7ccb44e34fe2de158e0450393f1683bsf buffered in memory, the thread used for the request is not freed while
e06a6bccd7ccb44e34fe2de158e0450393f1683bsf httpd waits until the pending data is sent to the client.</p>
e06a6bccd7ccb44e34fe2de158e0450393f1683bsf
57758b7ebacbd303cb1c004dd67dd8e5cc1055dbslive <p>The MPM assumes that the underlying <code>apr_pollset</code>
57758b7ebacbd303cb1c004dd67dd8e5cc1055dbslive implementation is reasonably threadsafe. This enables the MPM to
57758b7ebacbd303cb1c004dd67dd8e5cc1055dbslive avoid excessive high level locking, or having to wake up the listener
57758b7ebacbd303cb1c004dd67dd8e5cc1055dbslive thread in order to send it a keep-alive socket. This is currently
57758b7ebacbd303cb1c004dd67dd8e5cc1055dbslive only compatible with KQueue and EPoll.</p>
57758b7ebacbd303cb1c004dd67dd8e5cc1055dbslive
57758b7ebacbd303cb1c004dd67dd8e5cc1055dbslive</section>
57758b7ebacbd303cb1c004dd67dd8e5cc1055dbslive<section id="requirements"><title>Requirements</title>
1d9308ed0075062953a246d16bcda888a1be1adeslive <p>This MPM depends on <glossary>APR</glossary>'s atomic
1d9308ed0075062953a246d16bcda888a1be1adeslive compare-and-swap operations for thread synchronization. If you are
1d9308ed0075062953a246d16bcda888a1be1adeslive compiling for an x86 target and you don't need to support 386s, or
1d9308ed0075062953a246d16bcda888a1be1adeslive you are compiling for a SPARC and you don't need to run on
1d9308ed0075062953a246d16bcda888a1be1adeslive pre-UltraSPARC chips, add
ea8572f0df1c69b398e9d677648a0fa5f31b2d60pquerna <code>--enable-nonportable-atomics=yes</code> to the
ea8572f0df1c69b398e9d677648a0fa5f31b2d60pquerna <program>configure</program> script's arguments. This will cause
1d9308ed0075062953a246d16bcda888a1be1adeslive 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>
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim
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>
57758b7ebacbd303cb1c004dd67dd8e5cc1055dbslive
57758b7ebacbd303cb1c004dd67dd8e5cc1055dbslive <li>For Linux, a 2.6 kernel is recommended. It is also necessary to
57758b7ebacbd303cb1c004dd67dd8e5cc1055dbslive ensure that your version of <code>glibc</code> has been compiled
57758b7ebacbd303cb1c004dd67dd8e5cc1055dbslive with support for EPoll.</li>
57758b7ebacbd303cb1c004dd67dd8e5cc1055dbslive
57758b7ebacbd303cb1c004dd67dd8e5cc1055dbslive </ul>
57758b7ebacbd303cb1c004dd67dd8e5cc1055dbslive</section>
57758b7ebacbd303cb1c004dd67dd8e5cc1055dbslive
ea8572f0df1c69b398e9d677648a0fa5f31b2d60pquerna<directivesynopsis location="mpm_common"><name>CoreDumpDirectory</name>
ea8572f0df1c69b398e9d677648a0fa5f31b2d60pquerna</directivesynopsis>
ea8572f0df1c69b398e9d677648a0fa5f31b2d60pquerna<directivesynopsis location="mpm_common"><name>EnableExceptionHook</name>
ea8572f0df1c69b398e9d677648a0fa5f31b2d60pquerna</directivesynopsis>
5134273c2ebd6e114a62c905e2e945d8062ae3eecovener<directivesynopsis location="mod_unixd"><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>
3fa816e4832a1c70600bdfd6fc5ef60e9f1c18bbsf<directivesynopsis location="mpm_common"><name>MaxRequestWorkers</name>
ea8572f0df1c69b398e9d677648a0fa5f31b2d60pquerna</directivesynopsis>
ea8572f0df1c69b398e9d677648a0fa5f31b2d60pquerna<directivesynopsis location="mpm_common"><name>MaxMemFree</name>
ea8572f0df1c69b398e9d677648a0fa5f31b2d60pquerna</directivesynopsis>
be192cefa381d5bae6868034687471754cb43175sf<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>
5134273c2ebd6e114a62c905e2e945d8062ae3eecovener<directivesynopsis location="mod_unixd"><name>User</name>
ea8572f0df1c69b398e9d677648a0fa5f31b2d60pquerna</directivesynopsis>
ea8572f0df1c69b398e9d677648a0fa5f31b2d60pquerna
188a5ef97e793cb79096d1297a37747b1de03457sf<directivesynopsis>
188a5ef97e793cb79096d1297a37747b1de03457sf<name>AsyncRequestWorkerFactor</name>
188a5ef97e793cb79096d1297a37747b1de03457sf<description>Limit concurrent connections per process</description>
188a5ef97e793cb79096d1297a37747b1de03457sf<syntax>AsyncRequestWorkerFactor <var>factor</var></syntax>
188a5ef97e793cb79096d1297a37747b1de03457sf<default>2</default>
188a5ef97e793cb79096d1297a37747b1de03457sf<contextlist><context>server config</context> </contextlist>
188a5ef97e793cb79096d1297a37747b1de03457sf<compatibility>Available in version 2.3.13 and later</compatibility>
188a5ef97e793cb79096d1297a37747b1de03457sf
188a5ef97e793cb79096d1297a37747b1de03457sf<usage>
188a5ef97e793cb79096d1297a37747b1de03457sf <p>The event MPM handles some connections in an asynchronous way, where
188a5ef97e793cb79096d1297a37747b1de03457sf request worker threads are only allocated for short periods of time as
35e26fe7e0920b607afc63a645c846633f0e6889minfrin needed, and other connections with one request worker thread reserved per
35e26fe7e0920b607afc63a645c846633f0e6889minfrin connection. This can lead to situations where all workers are tied up and
35e26fe7e0920b607afc63a645c846633f0e6889minfrin no worker thread is available to handle new work on established async
35e26fe7e0920b607afc63a645c846633f0e6889minfrin connections.</p>
188a5ef97e793cb79096d1297a37747b1de03457sf
188a5ef97e793cb79096d1297a37747b1de03457sf <p>To mitigate this problem, the event MPM does two things: Firstly, it
188a5ef97e793cb79096d1297a37747b1de03457sf limits the number of connections accepted per process, depending on the
188a5ef97e793cb79096d1297a37747b1de03457sf number of idle request workers. Secondly, if all workers are busy, it will
188a5ef97e793cb79096d1297a37747b1de03457sf close connections in keep-alive state even if the keep-alive timeout has
188a5ef97e793cb79096d1297a37747b1de03457sf not expired. This allows the respective clients to reconnect to a
188a5ef97e793cb79096d1297a37747b1de03457sf different process which may still have worker threads available.</p>
188a5ef97e793cb79096d1297a37747b1de03457sf
188a5ef97e793cb79096d1297a37747b1de03457sf <p>This directive can be used to fine-tune the per-process connection
188a5ef97e793cb79096d1297a37747b1de03457sf limit. A process will only accept new connections if the current number of
850ba9505c2d10d3e26c648caa968a1d41c57395sf connections (not counting connections in the "closing" state) is lower
850ba9505c2d10d3e26c648caa968a1d41c57395sf than:</p>
188a5ef97e793cb79096d1297a37747b1de03457sf
188a5ef97e793cb79096d1297a37747b1de03457sf <p class="indent"><strong>
188a5ef97e793cb79096d1297a37747b1de03457sf <directive module="mpm_common">ThreadsPerChild</directive> +
188a5ef97e793cb79096d1297a37747b1de03457sf (<directive>AsyncRequestWorkerFactor</directive> *
188a5ef97e793cb79096d1297a37747b1de03457sf <var>number of idle workers</var>)
188a5ef97e793cb79096d1297a37747b1de03457sf </strong></p>
188a5ef97e793cb79096d1297a37747b1de03457sf
188a5ef97e793cb79096d1297a37747b1de03457sf <p>This means the absolute maximum numbers of concurrent connections is:</p>
188a5ef97e793cb79096d1297a37747b1de03457sf
188a5ef97e793cb79096d1297a37747b1de03457sf <p class="indent"><strong>
188a5ef97e793cb79096d1297a37747b1de03457sf (<directive>AsyncRequestWorkerFactor</directive> + 1) *
188a5ef97e793cb79096d1297a37747b1de03457sf <directive module="mpm_common">MaxRequestWorkers</directive>
188a5ef97e793cb79096d1297a37747b1de03457sf </strong></p>
188a5ef97e793cb79096d1297a37747b1de03457sf
188a5ef97e793cb79096d1297a37747b1de03457sf <p><directive module="mpm_common">MaxRequestWorkers</directive> was called
188a5ef97e793cb79096d1297a37747b1de03457sf <directive>MaxClients</directive> prior to version 2.3.13. The above value
188a5ef97e793cb79096d1297a37747b1de03457sf shows that the old name did not accurately describe its meaning for the event MPM.</p>
188a5ef97e793cb79096d1297a37747b1de03457sf
188a5ef97e793cb79096d1297a37747b1de03457sf <p><directive>AsyncRequestWorkerFactor</directive> can take non-integer
188a5ef97e793cb79096d1297a37747b1de03457sf arguments, e.g "1.5".</p>
188a5ef97e793cb79096d1297a37747b1de03457sf
188a5ef97e793cb79096d1297a37747b1de03457sf</usage>
188a5ef97e793cb79096d1297a37747b1de03457sf
188a5ef97e793cb79096d1297a37747b1de03457sf</directivesynopsis>
188a5ef97e793cb79096d1297a37747b1de03457sf
ea8572f0df1c69b398e9d677648a0fa5f31b2d60pquerna</modulesynopsis>