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