网络 I/O 序列化
为什么网络 I/O 是串行化而不是并行化?
Why is network I/O serialized and not parallelized?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
为什么网络 I/O 是串行化而不是并行化?
Why is network I/O serialized and not parallelized?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(5)
嗯,实际的数据包类型是(例如,它们都可以采用不同的路线),但在某些时候,您将需要一个流,您可以按照与您相同的顺序读取数据。把它放进去——这是 TCP 的一个关键点。否则你会怎么做?
您总是可以使用单独的套接字来提供额外的并行性吗?还是我误解了你的意思?
一些网络协议确实提供“广播”,但这并不总是可用(例如,许多网络设备会故意配置为阻止 UDP 广播)
Well, the actual packets kind of are (they could all take different routes, for example), but at some point you're going to want a stream where you read the data out in the same order you put it in - that being a key point of TCP. How else would you do this?
You could always use separate sockets to give additional parallelism? Or have I misunderstood your meaning?
Some network protocols do offer "broadcast", but this is not always available (for example many network devices such will deliberately be configured to block UDP broadcasts)
苹果和橙子。
序列化是指您获取一些结构化数据并将其扁平化为可以轻松实现的单个数据序列被传输,然后在另一端反序列化以重新创建原始结构。
并行化是指将一个任务划分为多个可以同时运行的子任务,然后将它们的结果结合起来得到相同的结果,就好像任务是由单个进程运行一样。
因此,并行化不能取代串行化,因为它们用于不同的目的。
Apples and oranges.
Serializing is when you take some structured data and flattens it into a single sequence of data that can easily be transmitted and then deserialized on the other end to recreate the original structure.
Parallelizing is when you divide a task in several sub-tasks that can be run simultaneously, and then combine their results to get the same thing as if the task was run by a single process.
So, parallelizing can not replace serializing as they are used for different purposes.
因为焊接电缆连接器比添加更多处理器能力(或添加更复杂的芯片以获得更高的生产线速度)更昂贵。比较多年来通常用于通信的电缆类型:
Centronics 并行电缆 - 36 针。
RS232 电缆 25 针,然后 9 针
以太网双绞线 - 两对(4 针)
USB 电缆 - 一对 + 电源。
此外,通过无线或长距离并行传输多个通道并不容易。
Because soldering cable connectors is more expensive than adding more processor power (or to add more complicated chips for greater line speed). Compare types of cables typically used for communication over years:
Centronics parallel cable - 36 pins.
RS232 cable 25 pins, then 9 pins
Ethernet twisted pair - two pairs (4 pin)
USB cable - one pair + power.
Moreover, it is not easy to transfer several channels in paralel over wireless or long distance.
将其视为数据流。数据可以分块并以无序的方式发送/接收。
为了重建原始流,必须对块重新排序。
Think it as a stream of data. The data can be chunked and sent/received in an unordered way.
To reconstruct the original stream the chunks have to be reordered.
首先,我现在的 AMD 机器正在运行具有 6CPU 核心的 Ubuntu Linux,并且“ps -ef”给出:
从上面,您可以看到很多内核进程都是每个 cpu 核心的 - 包括 ksoftirqd。查看linux内核文档,网络驱动程序使用ksoftirqd来实现数据的发送。所以这就是CPU核心级别的并行化。
在网卡上,有多个“通道”——特别是对于高速网卡。所有这些都可以同时处理数据的接收和传输——再次是网卡级别的并行化。例如:
http://www.colfaxdirect.com/store /pc/viewPrd.asp?idproduct=230&idcategory=0
(查找“多通道”)。
但是,当它到达以太网线时,由于它们都共享同一根电线......电线级别的序列化是必要的。但线路的带宽通常比CPU或以太网卡的处理速率高得多。
First, my present AMD machine is running Ubuntu Linux with 6CPU-core, and "ps -ef" gave:
From above, u can see that a lot of the kernel processes are per-cpu-core - including the ksoftirqd. Look into linux kernel documentation, networking drivers are using the ksoftirqd to implement the sending out of data. So this is parallelization at the CPU core level.
At the network card, there is multiple "channel" - especially for highspeed networking cards. And all these can process receiving and transmission of data at the same time - again parallelization at the network card level. Eg:
http://www.colfaxdirect.com/store/pc/viewPrd.asp?idproduct=230&idcategory=0
(look for "multi-channel").
But when it reach the ethernet wire, since all of them are sharing the same wire.....serialization at the wire level is necessary. But then the bandwidth of wire is usually MUCH higher than the processing rate of CPU or ethernet card.