Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Socket IO involve Disk IO?

If one process sends data through a socket to another process on the same machine how likely is it that a disk read/write will occur during transmission? There seems to be a socket file type, are these guaranteed to be in memory provided there is free memory?

like image 904
kaan_a Avatar asked Oct 26 '14 00:10

kaan_a


People also ask

What is difference between Socket and IO?

Key Differences between WebSocket and socket.ioIt provides the Connection over TCP, while Socket.io is a library to abstract the WebSocket connections. WebSocket doesn't have fallback options, while Socket.io supports fallback. WebSocket is the technology, while Socket.io is a library for WebSockets.

How does Socket.IO work?

Socket.IO allows bi-directional communication between client and server. Bi-directional communications are enabled when a client has Socket.IO in the browser, and a server has also integrated the Socket.IO package. While data can be sent in a number of forms, JSON is the simplest.

What is Socket.IO in node JS?

Socket.IO is a library that enables real-time, bidirectional and event-based communication between the browser and the server. It consists of: a Node. js server: Source | API. a Javascript client library for the browser (which can be also run from Node.


2 Answers

Not directly. TCP / UDP network sockets, over localhost, or a UNIX Domain Socket will operate in memory. UNIX Domain Sockets are typically the fastest option outside of dropping into kernel space with a module.

sockets over localhost pipes are nearly as simple as a couple of memcpy's between userspace and kernel space and back. In TCP case, you have the stack overhead.

Both files and sockets share the kernel abstraction of descriptor table, but that doesn't imply an actual file.

Of course, the database may trigger some write to a log, as a result of your transaction.

like image 152
codenheim Avatar answered Sep 16 '22 21:09

codenheim


In the POSIX model, as well as many other kernels, files are not only in disks. Instead, every device is represented by a "special file". They live in directories or some sort of namespace, but accessing them is not disk access, even if they are placed in a directory on disk.

If you have memory pressure, then it's possible for some of your data buffers to get swapped out. But this has nothing to do with the "file" nature of devices. It's just using the disk as additional RAM.

So "Yes, socket I/O is file I/O, but not disk read/write."

like image 41
Ben Voigt Avatar answered Sep 20 '22 21:09

Ben Voigt