增大socket缓存
方法是通过sysctl的相关选项:
net.core.rmem_default = 26214400
net.core.rmem_max = 26214400
net.core.wmem_default = 26214400
net.core.wmem_max = 26214400
可以保存入一个文本文件,如/tmp/sample.conf,之后通过
sysctl -p /tmp/sample.conf
来加载。
也可以通过
sysctl -w net.core.rmem_max=26214400
直接加载。
增大网卡的发送、接收队列
假设网卡为eth0,
先通过
ethtool -g eth0
来查看网卡的发送、接收队列,
如:
Ring parameters for eth0:
Pre-set maximums:
RX: 4096
RX Mini: 0
RX Jumbo: 0
TX: 4096
Current hardware settings:
RX: 256
RX Mini: 0
RX Jumbo: 0
TX: 256
则说明,网卡的队列是256,但是最大可以设置到4096,我们通过
ethtool -G
来设置网卡的队列。
如:
ethtool -G eth0 rx 4096
设置接收队列为4096。
本文介绍了如何通过调整sysctl参数增大socket缓冲区大小,以提升网络通信性能。设置了net.core.rmem_default、rmem_max、wmem_default和wmem_max的值为26214400。同时,讲解了如何使用ethtool工具增加网卡eth0的接收和发送队列,将RX和TX队列从256提升到4096,以优化网络吞吐能力。
808

被折叠的 条评论
为什么被折叠?



