From owner-freebsd-hackers Thu Apr 3 09:56:36 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id JAA05771 for hackers-outgoing; Thu, 3 Apr 1997 09:56:36 -0800 (PST) Received: from scanner.worldgate.com (scanner.worldgate.com [198.161.84.3]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id JAA05766 for ; Thu, 3 Apr 1997 09:56:34 -0800 (PST) Received: from znep.com (uucp@localhost) by scanner.worldgate.com (8.8.5/8.7.3) with UUCP id KAA06075; Thu, 3 Apr 1997 10:56:06 -0700 (MST) Received: from localhost (marcs@localhost) by alive.znep.com (8.7.5/8.7.3) with SMTP id KAA01937; Thu, 3 Apr 1997 10:50:20 -0700 (MST) Date: Thu, 3 Apr 1997 10:50:19 -0700 (MST) From: Marc Slemko To: Bakul Shah cc: Guido van Rooij , FreeBSD-hackers Subject: Re: apache like preforking apps and high loads In-Reply-To: <199704031653.LAA20772@chai.plexuscom.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk On Thu, 3 Apr 1997, Bakul Shah wrote: > > >When looking at Apacha like applications, one often sees extermely high > > >load averages. Apache preforks a number of processes that all block > > >on accept(). When a request comes in, all process are woken up and the > > >scheduler chooses one of the now runnable processes taht will succeed in > > >the accept(). The other go back to sleep. > > > > Not any more. I changed this a few days ago. Now only one process is > > woken up. > > Fairness is probably not an issue when an app. consists of a number > of anonymous servers but in general one would want to make sure that > if N processes are waiting on accept() on the same socket, no one > process is starved of accepting. How do you ensure that? For something like Apache you want the _least_ equal distribution possible, ie. a stack of most recently used processes from which you pop a server to process a request. Right now, if you have 100 servers running and get requests at a rate that one could handle, all of them will still be used. This is bad; it hurts locality of reference a lot. On some architectures, it has a significant impact WRT caching, and also means that if you don't have enough RAM for all server processes then they will each end up being swapped out and in again. The reason why Apache doesn't do this is the implementation details. It is difficult to get a good implementation that is efficient (so you don't create more overhead than you remove) and portable. Sort of timed destruction of child processes could help; right now you are limited to how it is hard coded in Apache and if you set MaxSpareServers too low you run into problems with short term load fluctuations. > To guido: For apache like apps one idea is to have one process be > the acceptor and have it pass a new socket to individual server > processes (including doing some initial processing to determine > which process should get this socket if not all server processes are > equivalent). This has a lot of portability issues and can lead to running into things such as per process fd limits more quickly on some architectures.