为了达到最大网络吞吐,socket send buffer size(SO_SNDBUF)不应该小于带宽和延迟的乘积。
之前我遇到2个性能问题,都和SO_SNDBUF设置得太小有关。
但是,写程序的时候可能并不知道把SO_SNDBUF设多大合适,而且SO_SNDBUF也不宜设得太大,浪费内存啊。
于是,有OS提供了动态调整缓冲大小的功能,这样应用程序就不用再对SO_SNDBUF调优了。
(接受缓冲SO_RCVBUF也是类似的问题,不应该小于带宽和延迟的乘积)。
On Linux:Linux从2.4开始支持接收缓冲和发送缓冲的动态调整。
------------------------------------------------------------
tcp_rmem (since Linux 2.4)
This is a vector of 3 integers: [min, default, max]. These
parameters are used by TCP to regulate receive buffer sizes.
TCP dynamically adjusts the size of the receive buffer from
the defaults listed below, in the range of these values,
depending on memory available in the system.
...
tcp_wmem (since Linux 2.4)
This is a vector of 3 integers: [min, default, max]. These
parameters are used by TC
最后
以上就是懦弱机器猫最近收集整理的关于linux 调整buffer大小,关于socket buffer size的调优的全部内容,更多相关linux内容请搜索靠谱客的其他文章。
发表评论 取消回复