Discussion: Unix sockets are (usually) faster than TCP/IP. Does it matter (to you)?

In the context of Nextcloud, specifically


Just curious about what everyoneā€™s feelings on the matter are. Personally, when I first started self-hosting, Unix sockets were scary. TCP/IP connections are defined by an IP address or hostname, both of which are relatively familiar to amateurs.

Recently, however, I completely rebuilt my Nextcloud installation from scratch and used Unix sockets, mostly just for the challenge of doing something Iā€™d never done before.

I canā€™t tell the difference.

Maybe thereā€™s a few milliseconds difference server-side, but those gains are more than nullified by the variations in latency between host and client, client script processing, and a multitude of other factors.

I also donā€™t care. Iā€™m sticking with my setup.


So, what about you? Are you ā€˜Team Unix Socketsā€™ all day, or is TCP/IP ā€˜fast enoughā€™?

Iā€™d be especially interested to hear the perspective of anyone who has deployed Nextcloud at scale (100+ users).


P.S.
This is a Discussion Question, not a declaration of war or ā€˜how do I do thisā€™ or another ā€˜are sockets fasterā€™ question. Just in case anyone was confused.

5 Likes

I always use sockets, and for me it was the simplicity to set up a socket. It just runs locally, no need to pay attention not to expose a service to the outside world. Performance-wise, it was nice to know that it is probably better.

One difference might be, that you start to use multiple servers (e.g. web-frontend servers, they connect to a database/storage backend), so you need ā€œrealā€ network connections.

1 Like

I would add the caveat that theyā€™re simple to set up on bare metal and VMs. Containers (Docker, Podman, etc.) add a layer of complexity to the entire process.

You have to figure out where ā€˜thatā€™ particular configuration file is located in ā€˜thisā€™ particular image, make sure itā€™s mounted to the host so your edits are persistent, define the socket, mount it to the host so other containers can use it, and then make sure everyone has the correct permissions to do so.

And then you repeat the process for the other container(s).

Fun.

I spent about three hours getting a Redis container to listen on a socket, a process that would have taken about three minutes otherwise.

2 Likes