for local communication only - UNIX or INET?
I'm mostly curious - wath are the pros and cons of using a local UNIX socket vs. an INET socket? E.g. having a daemon listen on /var/lib/xxx/yyy.soc instead of localhost:nnnnn ? (it is assumed that everyone involved will have the choice of using either one). Any likely performance impacts (positive or negative)? /Per Jessen, Zürich
On Thu, 15 Jun 2006, Per Jessen wrote:
I'm mostly curious - wath are the pros and cons of using a local UNIX socket vs. an INET socket? E.g. having a daemon listen on /var/lib/xxx/yyy.soc instead of localhost:nnnnn ? (it is assumed that everyone involved will have the choice of using either one).
Any likely performance impacts (positive or negative)?
One downside to using UNIX sockets: You have to use them on the same machine. You cannot connect between machines with them. Upside to using INET sockets: You can use them on the one machine or connect across machines. Most people program with the INET sockets just in case they ever need to connect between machines. I'm not well-versed in whether there are any performance or security issues of one over the other. -- Curt, WE7U. APRS Client Comparisons: http://www.eskimo.com/~archer "Lotto: A tax on people who are bad at math." -- unknown "Windows: Microsoft's tax on computer illiterates." -- WE7U "The world DOES revolve around me: I picked the coordinate system!"
On Thu, 15 Jun 2006, 15:34:27 +0200, Curt, WE7U wrote:
On Thu, 15 Jun 2006, Per Jessen wrote:
I'm mostly curious - wath are the pros and cons of using a local UNIX socket vs. an INET socket? E.g. having a daemon listen on /var/lib/xxx/yyy.soc instead of localhost:nnnnn ? (it is assumed that everyone involved will have the choice of using either one).
Any likely performance impacts (positive or negative)?
One downside to using UNIX sockets: You have to use them on the same machine. You cannot connect between machines with them.
Upside to using INET sockets: You can use them on the one machine or connect across machines.
Most people program with the INET sockets just in case they ever need to connect between machines.
I'm not well-versed in whether there are any performance or security issues of one over the other.
As Curt pointed out, UNIX sockets can only be used if you are sure, communication will only be on the local machine. But performance will actually *really* benefit if you're using UNIX vs INET sockets: I ran a small client/server combo which just exchanges messages of length 8 KiB; here are the results: UNIX sockets on local machine: $ ./lclient dummy MBytes per sec. : 262.23 MBytes per sec. : 284.34 MBytes per sec. : 293.61 MBytes per sec. : 307.26 MBytes per sec. : 355.33 INET sockets between two machines connected via GigE: $ ./gclient saturn MBytes per sec. : 99.18 MBytes per sec. : 94.13 MBytes per sec. : 102.68 MBytes per sec. : 103.58 MBytes per sec. : 103.69 MBytes per sec. : 97.92 MBytes per sec. : 103.15 But remember, there are several items to be considered: - bandwidth/throughput of the local system - bandwidth/throughput/latency of your network - resulting load on the system(s) If you know communication will always be local to the machines the applications are running on, use UNIX sockets; it might (actually it will!) result in higher load on the system, though, as both client and server are running on the same system. HTH, cheers. l8er manfred
Manfred Hollstein wrote:
As Curt pointed out, UNIX sockets can only be used if you are sure, communication will only be on the local machine. But performance will actually *really* benefit if you're using UNIX vs INET sockets:
Manfred, thanks, that was quite helpful. The daemon I'm writing/using will be supporting UNIX and INET sockets (doing both is no big deal), but in some situations both client and server will be on the same machine, and I was wondering about the performance.
UNIX sockets on local machine: $ ./lclient dummy MBytes per sec. : 262.23 MBytes per sec. : 284.34 MBytes per sec. : 293.61 MBytes per sec. : 307.26 MBytes per sec. : 355.33
INET sockets between two machines connected via GigE: $ ./gclient saturn MBytes per sec. : 99.18 MBytes per sec. : 94.13 MBytes per sec. : 102.68 MBytes per sec. : 103.58 MBytes per sec. : 103.69 MBytes per sec. : 97.92 MBytes per sec. : 103.15
You wouldn't happen to also have some numbers for "INET sockets on local machine"? /Per Jessen, Zürich
Hi Per, On Thu, 15 Jun 2006, 20:30:59 +0200, Per Jessen wrote:
Manfred Hollstein wrote:
As Curt pointed out, UNIX sockets can only be used if you are sure, communication will only be on the local machine. But performance will actually *really* benefit if you're using UNIX vs INET sockets:
Manfred,
thanks, that was quite helpful. The daemon I'm writing/using will be supporting UNIX and INET sockets (doing both is no big deal), but in some situations both client and server will be on the same machine, and I was wondering about the performance.
UNIX sockets on local machine: $ ./lclient dummy MBytes per sec. : 262.23 MBytes per sec. : 284.34 MBytes per sec. : 293.61 MBytes per sec. : 307.26 MBytes per sec. : 355.33
INET sockets between two machines connected via GigE: $ ./gclient saturn MBytes per sec. : 99.18 MBytes per sec. : 94.13 MBytes per sec. : 102.68 MBytes per sec. : 103.58 MBytes per sec. : 103.69 MBytes per sec. : 97.92 MBytes per sec. : 103.15
You wouldn't happen to also have some numbers for "INET sockets on local machine"?
Good catch! Appears that the Linux TCP stack is dealing *very well* with local INET sockets: $ ./gclient localhost MBytes per sec. : 769.15 MBytes per sec. : 736.10 MBytes per sec. : 693.76 MBytes per sec. : 704.09 MBytes per sec. : 666.63 $ ./gclient saturn MBytes per sec. : 720.64 MBytes per sec. : 731.70 MBytes per sec. : 659.83 MBytes per sec. : 741.61 MBytes per sec. : 716.62 localhost and saturn are the same physical machine. Hmm, zero-copying at its best. This means, you're always better using INET sockets; now, that's new to me... I remember running the same test on several Sun machines (SunOS 4.1.4, Solaris 2.6) years ago, and the results were clearly punishing users of INET sockets on local machines... Linux rules D) Cheers. l8er manfred
Manfred Hollstein wrote:
You wouldn't happen to also have some numbers for "INET sockets on local machine"?
Good catch! Appears that the Linux TCP stack is dealing *very well* with local INET sockets:
$ ./gclient localhost MBytes per sec. : 769.15 MBytes per sec. : 736.10 MBytes per sec. : 693.76 MBytes per sec. : 704.09 MBytes per sec. : 666.63
$ ./gclient saturn MBytes per sec. : 720.64 MBytes per sec. : 731.70 MBytes per sec. : 659.83 MBytes per sec. : 741.61 MBytes per sec. : 716.62
Wow.
localhost and saturn are the same physical machine. Hmm, zero-copying at its best. This means, you're always better using INET sockets; now, that's new to me... I remember running the same test on several Sun machines (SunOS 4.1.4, Solaris 2.6) years ago, and the results were clearly punishing users of INET sockets on local machines...
It sounds like using UNIX sockets is a thing of the past. With that kind of performance, why would anyone use them? /Per Jessen, Zürich
Am Friday 16 June 2006 11:41 schrieb Per Jessen:
You wouldn't happen to also have some numbers for "INET sockets on local machine"?
Good catch! Appears that the Linux TCP stack is dealing *very well* with local INET sockets:
$ ./gclient localhost MBytes per sec. : 769.15 MBytes per sec. : 736.10 MBytes per sec. : 693.76 MBytes per sec. : 704.09 MBytes per sec. : 666.63
$ ./gclient saturn MBytes per sec. : 720.64 MBytes per sec. : 731.70 MBytes per sec. : 659.83 MBytes per sec. : 741.61 MBytes per sec. : 716.62
Wow.
localhost and saturn are the same physical machine. Hmm, zero-copying at its best. This means, you're always better using INET sockets; now, that's new to me... I remember running the same test on several Sun machines (SunOS 4.1.4, Solaris 2.6) years ago, and the results were clearly punishing users of INET sockets on local machines...
It sounds like using UNIX sockets is a thing of the past. With that kind of performance, why would anyone use them?
Security. -- Andreas
On Fri, 2006-06-16 at 12:12 +0200, Andreas Winkelmann wrote:
Am Friday 16 June 2006 11:41 schrieb Per Jessen:
You wouldn't happen to also have some numbers for "INET sockets on local machine"?
Good catch! Appears that the Linux TCP stack is dealing *very well* with local INET sockets:
$ ./gclient localhost MBytes per sec. : 769.15 MBytes per sec. : 736.10 MBytes per sec. : 693.76 MBytes per sec. : 704.09 MBytes per sec. : 666.63
$ ./gclient saturn MBytes per sec. : 720.64 MBytes per sec. : 731.70 MBytes per sec. : 659.83 MBytes per sec. : 741.61 MBytes per sec. : 716.62
Wow.
localhost and saturn are the same physical machine. Hmm, zero-copying at its best. This means, you're always better using INET sockets; now, that's new to me... I remember running the same test on several Sun machines (SunOS 4.1.4, Solaris 2.6) years ago, and the results were clearly punishing users of INET sockets on local machines...
It sounds like using UNIX sockets is a thing of the past. With that kind of performance, why would anyone use them?
Security.
If Linux is not the only target platform? Don't want to do the Linux version of 'if it works on Windows...". -- Roger Oberholtzer OPQ Systems AB Ramböll Sverige AB Kapellgränd 7 P.O. Box 4205 SE-102 65 Stockholm, Sweden Tel: Int +46 8-615 60 20 Fax: Int +46 8-31 42 23
Roger Oberholtzer wrote:
It sounds like using UNIX sockets is a thing of the past. With that kind of performance, why would anyone use them?
Security.
If Linux is not the only target platform? Don't want to do the Linux version of 'if it works on Windows...".
Roger, are you saying that you would use a UNIX socket instead of an INET socket to enable compatibility with more/other platforms? That doesn't sound right - shouldn't it be the other way, i.e. use an INET socket to get more compability? After all, who would try to port a network application on to a platform with no TCP stack ... /Per Jessen, Zürich
Andreas Winkelmann wrote:
It sounds like using UNIX sockets is a thing of the past. With that kind of performance, why would anyone use them?
Security.
But what are the security implications of using a local UNIX sockets vs. using localhost:nnnn ?? /Per Jessen, Zürich
Am Friday 16 June 2006 14:29 schrieb Per Jessen:
It sounds like using UNIX sockets is a thing of the past. With that kind of performance, why would anyone use them?
Security.
But what are the security implications of using a local UNIX sockets vs. using localhost:nnnn ??
How do you control the access to your inet-Socket? Each User on the System can connect to your Application. With unix-Sockets, the Filesystem controls who is able to access the Socket. There is no work to be done from the Developer. -- Andreas
Andreas Winkelmann wrote:
But what are the security implications of using a local UNIX sockets vs. using localhost:nnnn ??
How do you control the access to your inet-Socket? Each User on the System can connect to your Application. With unix-Sockets, the Filesystem controls who is able to access the Socket. There is no work to be done from the Developer.
Interesting point, Andreas. I hadn't considered that at all. /Per Jessen, Zürich
participants (5)
-
Andreas Winkelmann
-
Curt, WE7U
-
Manfred Hollstein
-
Per Jessen
-
Roger Oberholtzer