gpt4 book ai didi

javascript - 为什么有人会关闭 Nagle 的算法?

转载 作者:IT王子 更新时间:2023-10-29 05:58:48 29 4
gpt4 key购买 nike

来自 Node redis docs :

socket_nodelay: defaults to true. Whether to call setNoDelay() on the TCP stream, which disables the Nagle algorithm on the underlying socket. Setting this option to false can result in additional throughput at the cost of more latency. Most applications will want this set to true.

我为什么要关闭 Nagle 算法?

最佳答案

当您担心延迟时,您可能希望关闭 Nagle 算法。我对该算法的理解是,它会延迟发送数据,直到有合理的发送量为止。这反过来又减少了流的协议(protocol)开销,因为更多的数据在单个数据包中发送(即具有单个 header )。

在关闭 Nagle 算法的情况下,想法是数据由协议(protocol)栈立即发送。

它是在网络资源更加受限的时代设计的,因此减少开销比权宜交付更为重要。然而,如今随着互连速度普遍加快以及对低延迟的要求越来越高,它变得不那么重要了。 (想想视频流!)

关于javascript - 为什么有人会关闭 Nagle 的算法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9614934/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com