Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does unix domain socket perform any file system read write?

Using memcached with unix domain sockets, is there any filesystem read / write ? If it does : isn't this a down side for the tools which are tries to decrease or totally clear away any file system operation ?

Or in another way to ask, Is there any possibility to use only memory for the unix domain socket ?

I'm still not sure Whether Unix Domain Sockets uses file system or not, I'm not the C guy but little overview about the https://github.com/torvalds/linux/blob/master/net/unix/af_unix.c implementation, that I see there are filesystem usages. So isn't that work on just memory ?

Edit : After reading my question and the description, I'm aware I asked lots of question and the question itself is almost different than the description. I want to fill information gaps in my mind, sorry for the mixed question.

like image 734
FZE Avatar asked Mar 12 '23 20:03

FZE


1 Answers

The linux kernel per-se does not persist any internal data or application data. You can use all kernel features without having a disk mounted at all.

You have to differentiate between filesystem and disks. A filesystem can be completely virtual, it can reside in memory, or on the network.

Some POSIX operations use paths as unique identifiers, including UNIX Domain Sockets. The path is only there as an identifier. You can place it in a tmpfs for example to avoid any disk usage. On a modern Linux system, /tmp/ is typically mounted to a tmpfs.

Note that even if your socket end-point lies within a filesystem residing on a disk, the disk usage is still negligible. As the path is only used to identify/find the socket itself, none of the actual data is ever written on the disk. And the kernel will also cache the path in memory.

like image 130
ypnos Avatar answered Apr 06 '23 23:04

ypnos