I'm trying to figure out the maximum possible number of concurrently
served requests. I do this to pre-allocate locks, which can be precious
resources, so I don't want to over-estimate.
It seems that it should be the smallest of the:
(max allowed threads * max allowed processes) OR max clients
In prefork.c, max procs appears to be the value of
AP_MPMQ_MAX_DAEMON_USED, while AP_MPMQ_MAX_DAEMON is the ServerLimit
(which does not take into account MaxClients). So given prefork as an
example, the following should work (pseudo code):
threads, daemons = 0
if IS_THREADED
threads = MAX_THREADS
if IS_FORKED
daemons = MAX_DAEMON_USED
total = threads * daemons
*However*, the story is different with worker. Here, the
MaxClient-adjusted max daemons is AP_MPMQ_MAX_DAEMONS, while
AP_MPMQ_MAX_DAEMON_USED is -1 (at least at server startup). So going by
the worker code, it looks like this:
threads, daemons = 0
if IS_THREADED
threads = MAX_THREADS
if IS_FORKED
daemons = MAX_DAEMONS
total = threads * daemons
*So* it seems that code that would really work (and only on start up) for
either mpm is:
threads, daemons = 0
if IS_THREADED
threads = MAX_THREADS
if IS_FORKED
daemons = MAX_DAEMON_USED
if daemons == -1
daemons = MAX_DAEMON
total = threads * daemons
But was it really meant to be this way?
Should in prefork.c:
case AP_MPMQ_MAX_DAEMONS:
*result = server_limit;
return APR_SUCCESS;
really be
case AP_MPMQ_MAX_DAEMONS:
if (ap_daemons_limit == -1) {
*result = server_limit;
}
else {
*result = (server_limit < ap_daemons_limit) ?
server_limit : ap_daemons_limit
}
return APR_SUCCESS;
AND
case AP_MPMQ_MAX_DAEMON_USED:
*result = ap_daemons_limit;
really be
case AP_MPMQ_MAX_DAEMON_USED:
*result = ap_max_daemons_limit;
Grisha