5 ms·
AF_VSOCK is another one to consider these days. It's a kind of hybrid of loopback and Unix. Although they are designed for communicating between virtual machi
by rwmj 3y ago
AF_VSOCK is another one to consider these days. It's a kind of hybrid of loopback and Unix. Although they are designed for communicating between virtual machines, vsock sockets work just as well between regular processes. Also supported on Windows.
https://www.man7.org/linux/man-pages/man7/vsock.7.html https://www.man7.org/linux/man-pages/man7/vsock.7.html
https://wiki.qemu.org/Features/VirtioVsock https://wiki.qemu.org/Features/VirtioVsock
- cout 3y agoI did not know about this. Thanks for the tip!
- touisteur 3y agoWith some luck and love in the future hopefully we'll also be able to use them in containers https://patchwork.kernel.org/project/kvm/cover/20200116172428.311437-1-sgarzare@redhat.com/ https://patchwork.kernel.org/project/kvm/cover/2020011617242... which would simplify a lot of little things.
- tptacek 3y agoWhat's the advantage to vsocks over Unix domain sockets? UDS's are very fast, and much easier to use.
- rwmj 3y agoI didn't mean to imply any advantage, just that they are another socket-based method for two processes to communicate. Since vsocks use a distinct implementation they should probably be benchmarked alongside Unix domain sockets and loopback sockets in any comparisons. My expectation is they would be somewhere in the middle - not as well optimized as Unix domain sockets, but with less general overhead than TCP loopback. If you are using vsocks between two VMs as intended then they have the advantage that they allow communication without involving the network stack. This is used by VMs to implement guest agent communications (screen resizing, copy and paste and so on) where the comms don't require the network to have been set up at all or be routable to the host.
- coppsilgold 3y agoVMM's such as firecracker and cloud-hypervisor translate between vsock and UDS. [1] In recent kernel versions, sockmap also has vsock translation: <https://github.com/torvalds/linux/commit/5a8c8b72f65f6b80b52b21a207a4ddc3011d6440 https://github.com/torvalds/linux/commit/5a8c8b72f65f6b80b52...> This allows for a sort of UDS "transparency" between guest and host. When the host is connecting to a guest, the use of a multiplexer UDS is required. [1] [1] <https://github.com/firecracker-microvm/firecracker/blob/main/docs/vsock.md https://github.com/firecracker-microvm/firecracker/blob/main...>