From owner-freebsd-performance@FreeBSD.ORG Fri Feb 25 15:33:10 2005 Return-Path: Delivered-To: freebsd-performance@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D452716A4CE for ; Fri, 25 Feb 2005 15:33:10 +0000 (GMT) Received: from gate.bitblocks.com (bitblocks.com [209.204.185.216]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9353E43D49 for ; Fri, 25 Feb 2005 15:33:10 +0000 (GMT) (envelope-from bakul@bitblocks.com) Received: from bitblocks.com (localhost [127.0.0.1]) by gate.bitblocks.com (8.13.1/8.13.1) with ESMTP id j1PFX4OS056850; Fri, 25 Feb 2005 07:33:04 -0800 (PST) (envelope-from bakul@bitblocks.com) Message-Id: <200502251533.j1PFX4OS056850@gate.bitblocks.com> To: "Baris Simsek" In-reply-to: Your message of "Fri, 25 Feb 2005 09:02:45 +0200." <20050225070246.35459.qmail@istanbul.enderunix.org> Date: Fri, 25 Feb 2005 07:33:04 -0800 From: Bakul Shah cc: freebsd-performance@freebsd.org Subject: Re: unix domain sockets vs. internet sockets X-BeenThere: freebsd-performance@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Performance/tuning List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Feb 2005 15:33:10 -0000 > I am coding a daemon program. I am not sure about which type of sockets i > should use. Could you compare ip sockets and unix domain sockets? My main > criterions are performance and protocol load. What are the differences > between impelementations of them at kernel level? If you *don't want* remote processes access to your daemon, use unix sockets and you don't have to worry about security issues as much. This is the main reason for choosing one over the other. You should also structure your code so that you can change the choice later (as well as use SSL if necessary). Answering what you didn't ask :-) Socket implementation performance differences is the wrong thing to worry about this early in the game. Instead of trying to make it `as fast as possible', it might make more sense to think about what is the expected load (or setting load goals) and how to meet the required performance by making sure the machine has enough resources and making sure you can measure relevant performance parameters at any time. How you modularize your daemon, protocol design (if you have control over it), available memory, disk speed and data organization (if you are accessing lots of data), algorithm design, whether you can distribute load across machines etc. will have a much bigger influence on overall performance than the choice of socket type. You *never* have enough time to optimize everything so setting realistic performance goals helps you meet them sooner -- you fix the top N bottlenecks (which change as you tighten things) and stop when done!