You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "Gregory (Grisha) Trubetskoy" <gr...@apache.org> on 2003/10/15 23:03:07 UTC

mpm_query confusion (prefork.c bug?)

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

Re: mpm_query confusion (prefork.c bug?)

Posted by "Gregory (Grisha) Trubetskoy" <gr...@apache.org>.
On Wed, 15 Oct 2003, Gregory (Grisha) Trubetskoy wrote:

> 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
>

Before someone else corrects me, threads and daemons above should of
course default to 1, not 0, because x * 0 is 0 always, but everything else
is still true.

Grisha