From: Luca Toscano The
To use the Run-time configuration directives are identical to those provided by 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 The improved connection handling may not work for certain connection
- filters that have declared themselves as incompatible with event. In these
- cases, this MPM will fall back to the behaviour of the
- A similar restriction is currently present for requests involving an
- output filter that needs to read and/or modify the whole response body,
- like for example mod_ssl, mod_deflate, or mod_include. If the
- connection to the client blocks while the filter is processing the
- data, and the amount of data produced by the filter is too big to be
- buffered in memory, the thread used for the request is not freed while
- httpd waits until the pending data is sent to the client. The MPM assumes that the underlying --with-mpm=event to the apr_pollset
- 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.
The total amount of connections that a single process/threads block can handle is regulated
+ by the
Async connections would need a fixed dedicated worker thread with the previous MPMs but not with event.
+ The status page of
write() to the socket returns EWOULDBLOCK or EAGAIN, to become writable again after an idle time. The worker holding the socket might be able to offload the waiting task to the listener thread, that in turn will re-assign it to the first idle worker thread available once an event will be raised for the socket (for example, "the socket is now writable"). Please check the Limitations section for more information.
+ These improvements are valid for both HTTP/HTTPS connections.
+ +The improved connection handling may not work for certain connection
+ filters that have declared themselves as incompatible with event. In these
+ cases, this MPM will fall back to the behaviour of the
+
A similar restriction is currently present for requests involving an + output filter that needs to read and/or modify the whole response body, + like for example mod_ssl, mod_deflate, or mod_include. If the + connection to the client blocks while the filter is processing the + data, and the amount of data produced by the filter is too big to be + buffered in memory, the thread used for the request is not freed while + httpd waits until the pending data is sent to the client. Please note that + this limitation is only a corner case, it does not mean that the event MPM + defaults to worker in presence of TLS/SSL connections and/or compression.
+ +To illustrate this point we can think about the following two situations:
+ serving a static asset (like a CSS file) versus serving content retrieved from
+ FCGI/CGI or a proxied server. The former is predictable, namely the event MPM
+ has full visibility on the end of the content and it can use events: the worker
+ thread serving the response content can flush the first bytes until EWOULDBLOCK
+ or EAGAIN is returned, delegating the rest to the listener. This one in turn
+ waits for an event on the socket, and delegates the work to flush the rest of the content
+ to the first idle worker thread. Meanwhile in the latter example (FCGI/CGI/proxed content)
+ the MPM can't predict the end of the response and a worker thread has to finish its work
+ before returning the control to the listener. The only alternative is to buffer the
+ response in memory, but it wouldn't be the safest option for the sake of the
+ server's stability and memory footprint.
+
The event model was made possible by the introduction of new APIs into the supported operating systems:
+Before these new APIs where made available, the traditional select and poll APIs had to be used.
+ Those APIs get slow if used to handle many connections or if the set of connections rate of change is high.
+ The new APIs allow to monitor much more connections and they perform way better when the set of connections to monitor changes frequently. So these APIs made it possible to write the event MPM, that scales much better with the typical HTTP pattern of many idle connections.
The MPM assumes that the underlying apr_pollset
+ 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.
This MPM depends on