Date: Tue, 10 Apr 2001 13:12:54 -0700 From: Alfred Perlstein <bright@wintelcom.net> To: Dan Phoenix <dphoenix@bravenet.com> Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: lockf in apache Message-ID: <20010410131254.V15938@fw.wintelcom.net> In-Reply-To: <Pine.BSO.4.21.0104101301060.24363-100000@gandalf.bravenet.com>; from dphoenix@bravenet.com on Tue, Apr 10, 2001 at 01:02:17PM -0700 References: <Pine.BSO.4.21.0104101301060.24363-100000@gandalf.bravenet.com>
next in thread | previous in thread | raw e-mail | index | archive | help
* Dan Phoenix <dphoenix@bravenet.com> [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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010410131254.V15938>