Commit 1a7e2114 authored by Luca Toscano's avatar Luca Toscano
Browse files

Merge r1772357, r1772399, r1772512 from trunk:

Add a section to mpm-event's documentation to advertise new changes

I tried to add a summary of Stefan's last patches just backported to
2.4.x today. I've read all of them and tried to report Stefan's comment
from PR 53555 as much as possible. Please review and let me know if I wrong
something incorrect or not precise enough.

Fixed some wording in mpm-event's doc page

Added some notes in mpm-event's doc page

Submitted by: elukey



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1774500 13f79535-47bb-0310-9956-ffa450edef68
parent be88bf2c
Loading
Loading
Loading
Loading
+68 −1
Original line number Diff line number Diff line
@@ -101,10 +101,77 @@ of the <directive>AsyncRequestWorkerFactor</directive>.</p>

    </section>

    <section id="graceful-close"><title>Graceful process termination and Scoreboard usage</title>
        <p>This mpm showed some scalability bottlenecks in the past leading to the following
        error: "<strong>scoreboard is full, not at MaxRequestWorkers</strong>".
        <directive module="mpm_common">MaxRequestWorkers</directive>
        limits the number of simultaneous requests that will be served at any given time
        and also the number of allowed processes
        (<directive module="mpm_common">MaxRequestWorkers</directive> 
        / <directive module="mpm_common">ThreadsPerChild</directive>), meanwhile
        the Scoreboard is a representation of all the running processes and
        the status of their worker threads. If the scoreboard is full (so all the
        threads have a state that is not idle) but the number of active requests
        served is not <directive module="mpm_common">MaxRequestWorkers</directive>,
        it means that some of them are blocking new requests that could be served
        but that are queued instead (up to the limit imposed by
        <directive module="mpm_common">ListenBacklog</directive>). Most of the times
        the threads are stuck in the Graceful state, namely they are waiting to
        finish their work with a TCP connection to safely terminate and free up a
        scoreboard slot (for example handling long running requests, slow clients
        or connections with keep-alive enabled). Two scenarios are very common:</p>
        <ul>
            <li>During a <a href="../stopping.html#graceful">graceful restart</a>.
            The parent process signals all its children to complete
            their work and terminate, while it reloads the config and forks new
            processes. If the old children keep running for a while before stopping,
            the scoreboard will be partially occupied until their slots are freed.
            </li>
            <li>When the server load goes down in a way that causes httpd to
            stop some processes (for example due to
            <directive module="mpm_common">MaxSpareThreads</directive>).
            This is particularly problematic because when the load increases again,
            httpd will try to start new processes.
            If the pattern repeats, the number of processes can rise quite a bit,
            ending up in a mixture of old processes trying to stop and new ones
            trying to do some work.
            </li>
        </ul>
        <p>From 2.4.24 onward, mpm-event is smarter and it is able to handle
        graceful terminations in a much better way. Some of the improvements are:</p>
        <ul>
            <li>Allow the use of all the scoreboard slots up to
            <directive module="mpm_common">ServerLimit</directive>.
            <directive module="mpm_common">MaxRequestWorkers</directive> and
            <directive module="mpm_common">ThreadsPerChild</directive> are used
            to limit the amount of active processes, meanwhile
            <directive module="mpm_common">ServerLimit</directive> 
            takes also into account the ones doing a graceful
            close to allow extra slots when needed. The idea is to use
            <directive module="mpm_common">ServerLimit</directive> to instruct httpd
            about how many overall processes are tolerated before impacting
            the system resources.
            </li>
            <li>Force gracefully finishing processes to close their
            connections in keep-alive state.</li>
            <li>During graceful shutdown, if there are more running worker threads
            than open connections for a given process, terminate these threads to
            free resources faster (which may be needed for new processes).</li>
            <li>If the scoreboard is full, prevent more processes to finish
            gracefully due to reduced load until old processes have terminated
            (otherwise the situation would get worse once the load increases again).</li>
        </ul>
        <p>The behavior described in the last point is completely observable via
        <module>mod_status</module> in the connection summary table through two new
        columns: "Slot" and "Stopping". The former indicates the PID and
        the latter if the process is stopping or not; the extra state "Yes (old gen)"
        indicates a process still running after a graceful restart.</p>
    </section>

    <section id="limitations"><title>Limitations</title>
        <p>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
        cases, this MPM will fall back to the behavior of the
        <module>worker</module> MPM and reserve one worker thread per connection.
        All modules shipped with the server are compatible with the event MPM.</p>