Does Socket IO involve Disk IO?

前端 未结 3 569
旧巷少年郎
旧巷少年郎 2021-02-05 14:45

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 soc

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-05 14:47

    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.

提交回复
热议问题