Discussion:
[zeromq-dev] TCP vs IPC on common host
Iggy Philly
2012-07-30 15:38:39 UTC
Permalink
I'm trying to understand the differences between using TCP and IPC between processes on the same linux host. I've seen various indications that the TCP and IPC infrastructures are the same so I'm wondering if there is any significant performance difference between the two protocols on the same host machine. Does the TCP protocol still go through the network stack if both ends are on the same host? Or could I expect performance to be similar? Thanks!
Chuck Remes
2012-07-30 15:51:13 UTC
Permalink
Post by Iggy Philly
I'm trying to understand the differences between using TCP and IPC between processes on the same linux host. I've seen various indications that the TCP and IPC infrastructures are the same so I'm wondering if there is any significant performance difference between the two protocols on the same host machine. Does the TCP protocol still go through the network stack if both ends are on the same host? Or could I expect performance to be similar?
This is a great example of a question that could be answered by running the "perf" examples and trying out the different transports to see any differences.

That's the only way to get a good answer for your environment.

On Windows, IPC is *currently* handled by opening up a local TCP connection through loopback. However, that could change in a future release and result in a performance change.

Same is true for Linux; more recent releases have a highly optimized kernel code path for IPC than for TCP to the same host. Try it and see.

On OSX, IPC is handled via UNIX domain sockets so that the performance relative to TCP is pretty similar. Future releases of OSX may change this.

You will also see performance differences depending on the size of your messages and the transport choice. Try it and see for *your app.*

When doing any benchmarking, it's important that your test run for 30 or more seconds. Any "performance test" that completes in a few seconds will be dominated by startup & shutdown time and therefore give you bogus numbers, so make sure it runs longer.

cr
Michel Pelletier
2012-07-30 21:26:31 UTC
Permalink
Post by Chuck Remes
On Windows, IPC is *currently* handled by opening up a local TCP connection
through loopback. However, that could change in a future release and result
in a performance change.
Same is true for Linux; more recent releases have a highly optimized kernel
code path for IPC than for TCP to the same host. Try it and see.
I always thought (and it looks to me by brief code inspection) that
Linux uses domain sockets as well.
Post by Chuck Remes
On OSX, IPC is handled via UNIX domain sockets so that the performance
relative to TCP is pretty similar. Future releases of OSX may change this.
-Michel
Steven McCoy
2012-07-30 23:20:54 UTC
Permalink
Post by Chuck Remes
Post by Chuck Remes
On Windows, IPC is *currently* handled by opening up a local TCP
connection
Post by Chuck Remes
through loopback. However, that could change in a future release and
result
Post by Chuck Remes
in a performance change.
Same is true for Linux; more recent releases have a highly optimized
kernel
Post by Chuck Remes
code path for IPC than for TCP to the same host. Try it and see.
I always thought (and it looks to me by brief code inspection) that
Linux uses domain sockets as well.
I think the point is Unix sockets are faster than TCP because of less
layers to traverse. Solaris is still I think the only OS that can bump
localhost TCP connections to Unix sockets.
--
Steve-o
Loading...