减少大容量 Intranet 应用程序通信中的网络延迟
我们有一组服务器应用程序,用于从设备/工具接收测量数据。消息传输时间是目前我们的主要瓶颈,因此我们有兴趣减少它以改进流程。工具和服务器应用程序之间的通信是通过在 Redhat Linux 上使用 C++ 进行的 TCP/IP 套接字进行的。
是否可以通过更改 TCP/IP 配置设置或调整 tcp 内核功能来减少使用硬件的消息传输时间? (我们可以牺牲安全性来换取速度,因为通信是在安全的内联网上进行的)
We have a set of server applications which receive measurement data from equipment/tools. Message transfer time is currently our main bottleneck, so we are interested in reducing it to improve the process. The communication between the tools and server applications is via TCP/IP sockets made using C++ on Redhat Linux.
Is it possible to reduce the message transfer time using hardware, by changing the TCP/IP configuration settings or by tweaking tcp kernel functions? (we can sacrifice security for speed, since communication is on a secure intranet)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
根据工作负载,在套接字连接上禁用 Nagle 算法 会有很大帮助。
当处理大量小消息时,我发现这会产生巨大的差异。
根据记忆,我相信 C++ 的套接字选项称为
TCP_NODELAY
Depending on the workload, disabling Nagle's Algorithm on the socket connection can help a lot.
When working with high volumes of small messages, i found this made a huge difference.
From memory, I believe the socket option for C++ was called
TCP_NODELAY
正如 @Jerry Coffin 提议的那样,您可以切换到 UDP。 UDP 是不可靠的协议,这意味着您可能会丢失数据包,或者它们可能以错误的顺序到达,或者被重复。因此,您需要在应用程序级别处理这些情况。由于您可能会丢失一些数据(正如您在评论中所述),因此无需重新传输(任何可靠协议中最复杂的部分)。您只需要删除过时的数据包即可。使用简单的序列编号即可完成。
是的,您可以使用 RTP(它具有序列编号),但您不需要它。对于您的简单案例来说,RTP 看起来有点大材小用。它具有许多其他功能,主要用于多媒体流。
[编辑]和类似的问题此处
As @Jerry Coffin proposed, you can switch to UDP. UDP is unreliable protocol, this means you can lose your packets, or they can arrive in wrong order, or be duplicated. So you need to handle these cases on application level. Since you can lose some data (as you stated in your comment) no need for retransmission (the most complicated part of any reliable protocol). You just need to drop outdated packets. Use simple sequence numbering and you're done.
Yes, you can use RTP (it has sequence numbering) but you don't need it. RTP looks like an overkill for your simple case. It has many other features and is used mainly for multimedia streaming.
[EDIT] and similar question here
在硬件方面,尝试英特尔服务器网卡并确保TCP 卸载引擎 (ToE) 已启用。
如果您想要更好的延迟,但要以牺牲goodput 考虑减少中断合并周期。有关更多详细信息,请参阅英特尔文档,因为它们提供了大量可配置参数。
On the hardware side try Intel Server NICs and make sure the TCP offload Engine (ToE) is enabled.
There is also an important decision to make between latency and goodput, if you want better latency at expense of goodput consider reducing the interrupt coalescing period. Consult the Intel documentation for further details as they offer quite a number of configurable parameters.
如果可以的话,减少延迟的明显步骤是从 TCP 切换到 UDP。
If you can, the obvious step to reduce latency would be to switch from TCP to UDP.
是的。
谷歌“TCP 帧大小”了解详细信息。
Yes.
Google "TCP frame size" for details.