From owner-freebsd-hackers Thu Nov 16 3:18:52 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from distortion.dk (distortion.dk [195.249.147.156]) by hub.freebsd.org (Postfix) with ESMTP id 2C20837B4CF for ; Thu, 16 Nov 2000 03:18:47 -0800 (PST) Received: from petri2000 ([194.192.131.97]) by distortion.dk (8.9.3/8.9.1) with SMTP id MAA87904; Thu, 16 Nov 2000 12:24:29 +0100 (CET) (envelope-from nicolai@petri.cc) Message-ID: <023301c04fbf$1f9c2ad0$6732a8c0@atomic.dk> From: "Nicolai Petri" To: Cc: References: Subject: Re: Multithreaded tcp-server or non-blocking ? Date: Thu, 16 Nov 2000 12:19:41 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > From: > On Thu, 16 Nov 2000, Nicolai Petri wrote: > > What's the best approach for a simple web-server(never more the 10 clients) > > Is it using pthread and a thread per connection . > That is probably simplest from a programming point of view. That's sounds fine to me.. :o) > > Or to make a > > non-blocking single thread server. > That will probably give you the best performance. It willl probably use > slightly less RAM as well but not enough to be of an issue unless you are > trying to fit in 4MB or something. I've got plenty of RAM. It's more a question of stability / simplicity. > > Can people show me some simple examples > > of the 2 techniques ? > As in web servers that use one or the other method or are you just after > software that uses pthreads and/or non blocking I/O? > For non blocking I/O you are probably after select, poll or kqueue. I'm quite lost here.. Is there a good reason for using kqueue instead of select/poll ? > I have a basic program that uses pthreads if that will help...it uses > kqueue as well although not for non blocking I/O. Its not finished but the > threading part works... I would love to see the code.. I'm having some stability problems with my own code. Maybe I can figure out where I went wrong. > > And what's the pro's and con's for the 2 methods ??? > > It really does depend on what you're trying to acheive...I'd tend to go > for the threads solution with the argument that the programmers time is > worth far more than the extra hardware it would take to make up any minor > performance penalty. I personally prefer the most simple and failsafe solution. Too much performance hunting will often give less understandable/debugable code. --- Thanks for your good answers. - Nicolai Petri To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message