From owner-freebsd-hackers Tue Apr 10 13:12:58 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from fw.wintelcom.net (ns1.wintelcom.net [209.1.153.20]) by hub.freebsd.org (Postfix) with ESMTP id 99AFB37B422 for ; Tue, 10 Apr 2001 13:12:54 -0700 (PDT) (envelope-from bright@fw.wintelcom.net) Received: (from bright@localhost) by fw.wintelcom.net (8.10.0/8.10.0) id f3AKCsV04334; Tue, 10 Apr 2001 13:12:54 -0700 (PDT) Date: Tue, 10 Apr 2001 13:12:54 -0700 From: Alfred Perlstein To: Dan Phoenix Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: lockf in apache Message-ID: <20010410131254.V15938@fw.wintelcom.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from dphoenix@bravenet.com on Tue, Apr 10, 2001 at 01:02:17PM -0700 X-all-your-base: are belong to us. Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG * Dan Phoenix [010410 13:02] wrote: > > > show alot of that in top > occasioanally....think that could be from nfs timeouts > or just waiting on mysql connections to come back? > > what are they generally from? They're using a lockfile around the select() call on the accept'ing socket. Basically, when apache is listening on multiple IPs/ports it needs to select() on several filedescriptors. The problem (under FreeBSD at least) is that whenever you have some process select()'ing on a descriptor and another process wants to do the same you get a "select collision", a collision requires that all processes waiting on the same select channel wake up then reassert thier desire to select. So... if you have 500 apache processes select()'ing and one wakes up to service a request, finished serving, then goes to select again, all the rest (499) have to wake up and reaffirm thier desire to select(). This doesn't scale very well at all. What apache does to fix this, is only allow one process to select() at any given time by keeping a lockf lock on a file while waiting in select(). When select returns it releases the lock and this allows another process to enter the select() call. It's still not as efficient because (under FreeBSD) I think this still can wakeup each process blocked on the lock, but it's still an order of magnitude better than having select() collisions. If you want to get it the most optimal, try to not specify individual IPs for apache to bind to. If you can tell apache to bind to only port 80 on "*" (all IPs) you'll get much better performance because then apache no longer needs to select, it only needs to accept() on a single socket which is the most optimal thing to do. You'll know if you've got the single select working if you see the majority of the apache processes in "accept" rather than "lockf". You might also want to check out using accept filters to get even more performance out of apache, see the accf_http manpage and check the apache docs for the compile time stuff you need to do to enable this. -- -Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org] Daemon News Magazine in your snail-mail! http://magazine.daemonnews.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message