套接字IO是否涉及磁盘IO? [英] Does Socket IO involve Disk IO?

查看:340
本文介绍了套接字IO是否涉及磁盘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?

推荐答案

不直接。 TCP / UDP网络套接字,localhost或UNIX域套接字将在内存中运行。 UNIX域套接字通常是使用模块进入内核空间之外的最快选择。

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.

通过localhost管道的套接字几乎与用户空间和内核之间的几个memcpy一样简单空间和背部。在TCP情况下,您有堆栈开销。

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.

这篇关于套接字IO是否涉及磁盘IO?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆