For comparison, the figure also shows the throughput of two Unix processes communicating through a UNIX domain socket stream on a native Linux system. ... ... these optimizations the authors achieve a maximum receive throughput of 970 Mb/s and transmit throughput of 3310 Mb/s.
In short, Unix domain sockets are secure in general. You can use POSIX permissions to lock down access to the file descriptor (FD) associated with the socket, and the server side can request information such as credentials and PID of clients before they can fully connect.
Socket Use In PracticeUnix sockets are usually used as an alternative to network-based TCP connections when processes are running on the same machine.
Fast Sockets realizes round-trip transfer times of 60 mi- croseconds and maximum transfer bandwidth of 33 MB/second between two UltraSPARC 1s connected by a Myrinet network.
Yes, local interprocess communication by unix domain sockets should be faster than communication by loopback localhost connections because you have less TCP overhead, see here.
This benchmark: https://github.com/rigtorp/ipc-bench provides latency and throughput tests for TCP sockets, Unix Domain Sockets (UDS), and PIPEs.
Here you have the results on a single CPU 3.3GHz Linux machine :
TCP average latency: 6 us
UDS average latency: 2 us
PIPE average latency: 2 us
TCP average throughput: 0.253702 million msg/s
UDS average throughput: 1.733874 million msg/s
PIPE average throughput: 1.682796 million msg/s
66% latency reduction and almost 7X more throughput explain why most performance-critical software has their own IPC custom protocol.
Redis benchmark shows unix domain socket can be significant faster than TCP loopback.
When the server and client benchmark programs run on the same box, both the TCP/IP loopback and unix domain sockets can be used. Depending on the platform, unix domain sockets can achieve around 50% more throughput than the TCP/IP loopback (on Linux for instance). The default behavior of redis-benchmark is to use the TCP/IP loopback.
However, this difference only matters when throughput is high.
Unix domain sockets are often twice as fast as a TCP socket when both peers are on the same host. The Unix domain protocols are not an actual protocol suite, but a way of performing client/server communication on a single host using the same API that is used for clients and servers on different hosts. The Unix domain protocols are an alternative to the interprocess communication (IPC) methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With