From owner-freebsd-questions@FreeBSD.ORG Tue Nov 13 10:39:56 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6155A322 for ; Tue, 13 Nov 2012 10:39:56 +0000 (UTC) (envelope-from erichfreebsdlist@alogreentechnologies.com) Received: from alogreentechnologies.com (alogreentechnologies.com [67.212.224.110]) by mx1.freebsd.org (Postfix) with ESMTP id 0DB298FC12 for ; Tue, 13 Nov 2012 10:39:55 +0000 (UTC) Received: from X220.ovitrap.com ([122.129.203.50]) (authenticated bits=0) by alogreentechnologies.com (8.13.1/8.13.1) with ESMTP id qADAdq2R000476; Tue, 13 Nov 2012 03:39:54 -0700 Date: Tue, 13 Nov 2012 17:39:52 +0700 From: Erich Dollansky To: Friedrich Locke Subject: Re: high performance server design approach Message-ID: <20121113173952.14e12497@X220.ovitrap.com> In-Reply-To: References: X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.6; amd64-portbld-freebsd10.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Nov 2012 10:39:56 -0000 Hi, On Tue, 13 Nov 2012 08:23:38 -0200 Friedrich Locke wrote: > 0) To have a single process "accepting" incoming connection on port > 80 and send the new socket fd to one of the http server in a > round-roubin manner, or if you have N cores, create N - X processes or threads for handling the requests. Leave at least one core for the OS, so, have X >= 2. I would not fork at all. Have the threads ready when the requests are coming. At least this is what I did several years ago achieving the highest performance. Make X a variable to be able to tune a bit. You also should have a memory pool available to avoid calls to malloc and free. You must have a limit for the memory pool. Free the memory in the pool time to time so others can make use of the memory too. > The first approach leads to n+1 process. The second to exactly n > process. You need at least one core for handling the tasks of the OS. If I remember right, I took 10% of the cores plus one which I did not use and I took at least one core. This is all from memory. So, please consider that I could have missed something out. > Erich