I have been thinking about the problem that the threaded mpm currently
experiences when all servers end up with 1 final worker thread finishing
a long request. Apache will not start any new servers (because the max are
already running), but there are no threads to process new requests.

I would like to separate the concepts of idle thread control and request
control and tune the design of both to be thread based rather than
server based  as they are now.
 
Idle processing would remain largely the same. Count the number of
idle threads and see if it falls within the min/max range. If not,
consider adjusting.
 
For request processing I suggest the following algorithm. First,
we need to add a directive config called max_total_threads. The
algorithm would then be:
     x = count_the_total_number_of_threads;
     y = count_the_total_number_of_servers;
     if (((x + threads_per_child) <= max_total_threads) &&
         (y < max_clients))
        start_a_new_server;
 
This allows max_clients to be set higher, even though the number
of threads per child is high because you could configure something
like the following:
 
max_clients = 250;         /* A very large scary number, but stick with me... */
threads_per_child = 100;   /* for a total of 25000 possible threads! */
 
max_total_threads = 300;   /* Max at any given time, out of that possible 25000. */
min_spare_threads = 20;
max_spare_threads = 50;
 
This means that there will be 3 servers at a minimum (* 100 threads = 300).
But, in the worst case, there could be as many as 201 servers running (each
with 1 thread still left, where  201 + 100 > 300 so no new servers can start).
 
If you have 201 requests still being processed, then the server is probably
relatively busy (as opposed to the current design where the server is nearly
idle). If a server that is tuned reasonably, given its hardware
capabilities, gets to this busy state then it is understandable that the
server is slow in processing new requests.

Thoughts?

-- 
Paul J. Reder
-----------------------------------------------------------
"The strength of the Constitution lies entirely in the determination of each
citizen to defend it.  Only if every single citizen feels duty bound to do
his share in this defense are the constitutional rights secure."
-- Albert Einstein

Reply via email to