summaryrefslogtreecommitdiffstats
path: root/docs/manual/mod/event.xml
blob: 81275a3a757749277093062b8d38e607d04d9da9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<?xml version="1.0"?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
<!-- $LastChangedRevision$ -->

<!--
 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements.  See the NOTICE file distributed with
 this work for additional information regarding copyright ownership.
 The ASF licenses this file to You under the Apache License, Version 2.0
 (the "License"); you may not use this file except in compliance with
 the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->

<modulesynopsis metafile="event.xml.meta">
<name>event</name>
<description>A variant of the <module>worker</module> MPM with the goal
of consuming threads only for connections with active processing</description>
<status>MPM</status>
<sourcefile>event.c</sourcefile>
<identifier>mpm_event_module</identifier>

<summary>
    <p>The <module>event</module> Multi-Processing Module (MPM) is
    designed to allow more requests to be served simultaneously by
    passing off some processing work to supporting threads, freeing up
    the main threads to work on new requests.  It is based on the
    <module>worker</module> MPM, which implements a hybrid
    multi-process multi-threaded server.  Run-time configuration
    directives are identical to those provided by
    <module>worker</module>.</p>

    <p>To use the <module>event</module> MPM, add
      <code>--with-mpm=event</code> to the <program>configure</program>
      script's arguments when building the <program>httpd</program>.</p>

</summary>

<seealso><a href="worker.html">The worker MPM</a></seealso>

<section id="how-it-works"><title>How it Works</title>
    <p>This MPM tries to fix the 'keep alive problem' in HTTP. After a client
    completes the first request, the client can keep the connection
    open, and send further requests using the same socket. This can
    save significant overhead in creating TCP connections. However,
    Apache HTTP Server traditionally keeps an entire child process/thread waiting
    for data from the client, which brings its own disadvantages. To
    solve this problem, this MPM uses a dedicated thread to handle both
    the Listening sockets, all sockets that are in a Keep Alive state,
    and sockets where the handler and protocol filters have done their work
    and the only remaining thing to do is send the data to the client. The
    status page of <module>mod_status</module> shows how many connections are
    in the mentioned states.</p>

    <p>The improved connection handling does not yet work for certain
    connection filters, in particular SSL. For SSL connections, this MPM will
    fall back to the behaviour of the <module>worker</module> MPM and
    reserve one worker thread per connection.</p>

    <p>The MPM assumes that the underlying <code>apr_pollset</code>
    implementation is reasonably threadsafe. This enables the MPM to
    avoid excessive high level locking, or having to wake up the listener
    thread in order to send it a keep-alive socket. This is currently
    only compatible with KQueue and EPoll.</p>

</section>
<section id="requirements"><title>Requirements</title>
    <p>This MPM depends on <glossary>APR</glossary>'s atomic
    compare-and-swap operations for thread synchronization. If you are
    compiling for an x86 target and you don't need to support 386s, or
    you are compiling for a SPARC and you don't need to run on
    pre-UltraSPARC chips, add
    <code>--enable-nonportable-atomics=yes</code> to the
    <program>configure</program> script's arguments. This will cause
    APR to implement atomic operations using efficient opcodes not
    available in older CPUs.</p>

    <p>This MPM does not perform well on older platforms which lack good
    threading, but the requirement for EPoll or KQueue makes this
    moot.</p>

    <ul>

      <li>To use this MPM on FreeBSD, FreeBSD 5.3 or higher is recommended.
      However, it is possible to run this MPM on FreeBSD 5.2.1, if you
      use <code>libkse</code> (see <code>man libmap.conf</code>).</li>

      <li>For NetBSD, at least version 2.0 is recommended.</li>

      <li>For Linux, a 2.6 kernel is recommended. It is also necessary to
      ensure that your version of <code>glibc</code> has been compiled
      with support for EPoll.</li>

    </ul>
</section>

<directivesynopsis location="mpm_common"><name>CoreDumpDirectory</name>
</directivesynopsis>
<directivesynopsis location="mpm_common"><name>EnableExceptionHook</name>
</directivesynopsis>
<directivesynopsis location="mod_unixd"><name>Group</name>
</directivesynopsis>
<directivesynopsis location="mpm_common"><name>Listen</name>
</directivesynopsis>
<directivesynopsis location="mpm_common"><name>ListenBacklog</name>
</directivesynopsis>
<directivesynopsis location="mpm_common"><name>SendBufferSize</name>
</directivesynopsis>
<directivesynopsis location="mpm_common"><name>MaxRequestWorkers</name>
</directivesynopsis>
<directivesynopsis location="mpm_common"><name>MaxMemFree</name>
</directivesynopsis>
<directivesynopsis location="mpm_common"><name>MaxConnectionsPerChild</name>
</directivesynopsis>
<directivesynopsis location="mpm_common"><name>MaxSpareThreads</name>
</directivesynopsis>
<directivesynopsis location="mpm_common"><name>MinSpareThreads</name>
</directivesynopsis>
<directivesynopsis location="mpm_common"><name>PidFile</name>
</directivesynopsis>
<directivesynopsis location="mpm_common"><name>ScoreBoardFile</name>
</directivesynopsis>
<directivesynopsis location="mpm_common"><name>ServerLimit</name>
</directivesynopsis>
<directivesynopsis location="mpm_common"><name>StartServers</name>
</directivesynopsis>
<directivesynopsis location="mpm_common"><name>ThreadLimit</name>
</directivesynopsis>
<directivesynopsis location="mpm_common"><name>ThreadsPerChild</name>
</directivesynopsis>
<directivesynopsis location="mpm_common"><name>ThreadStackSize</name>
</directivesynopsis>
<directivesynopsis location="mod_unixd"><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 connections.</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>