unix domain sockets vs. internet sockets
bakul at BitBlocks.com
Fri Feb 25 07:33:10 PST 2005
> 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
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!
More information about the freebsd-performance