From owner-freebsd-hackers Thu Nov 16 16:31:59 2000 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 6CE6337B4C5 for ; Thu, 16 Nov 2000 16:31:57 -0800 (PST) Received: (from bright@localhost) by fw.wintelcom.net (8.10.0/8.10.0) id eAH0VqF20904; Thu, 16 Nov 2000 16:31:52 -0800 (PST) Date: Thu, 16 Nov 2000 16:31:52 -0800 From: Alfred Perlstein To: FengYue Cc: Bakul Shah , freebsd-hackers@FreeBSD.ORG Subject: Re: Multithreaded tcp-server or non-blocking ? Message-ID: <20001116163152.E18037@fw.wintelcom.net> References: <200011162354.SAA07155@repulse.cnchost.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from fengyue@bluerose.windmoon.nu on Thu, Nov 16, 2000 at 04:15:28PM -0800 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG * FengYue [001116 16:15] wrote: > > On Thu, 16 Nov 2000, Bakul Shah wrote: > > ->Yes, this is definitely simpler and preferable when servicing > ->a small number of concurrent requests. But you have to spawn > ->off as many processes as the worst case number of concurrent > ->requests you want to service since while all the processes > ->are busy servicing, additional connections are not being > ->accepted (after the listen backlog is exhausted). By using > > Well, with some additional coding, the parent process could easily > monitor how many child processes are being used at a given time (like > using mmap() to create a shared memory region and have the > child process increases the busy_count...etc) > and then to decide if it needs to spawn off some more processes into > the pool based on the percentpage of > number_of_busy_processes/total_processes_in_the_pool. Just > like the way apache does it I guess. And, ofcoz, I agree that > there are some performance impact if too many processes blocking on the > accept() call. Actually FreeBSD uses wakeup_one() for accept(), the only problem is when your server must wait on more than one port/IP, then you need to use select(), however when many processes are selecting on the same descriptor it kills performance, that's why things like apache use semaphores or file locks instead of select. > But then again, we're just talking about an easy solution for a webserver > that only wants to handle no more than 15 clients at any given time:) Yes, it may be overkill. :) -- -Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org] "I have the heart of a child; I keep it in a jar on my desk." To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message