网络接口队列(NIC queues / 收发队列 / 多队列网卡)调优,核心目标是:减少丢包、降低延迟、提升吞吐、均衡 CPU 负载。下面从「概念 → 排查 → 调优手段 → 常见场景」系统说明。
现代网卡通常有:
关键关系:
网卡硬件队列 → 中断 → CPU → 协议栈
ethtool -S eth0 | grep -i drop
ethtool -S eth0 | grep -i miss
rx_droppedrx_missed_errorstx_timeoutethtool -g eth0
看:
RX(pre-set / current)TXcat /proc/interrupts | grep eth0
mpstat -P ALL 1
如果某个 CPU 100%,其他空闲 → 队列/中断不均衡。
ethtool -l eth0 # 查看
ethtool -L eth0 combined 8
建议:
ethtool -G eth0 rx 4096 tx 4096
经验值:
⚠️ 受网卡上限限制(ethtool -g)
# 假设 eth0-rx-0 对应 IRQ 45
echo 2 > /proc/irq/45/smp_affinity
irqbalance
或:
set_irq_affinity.sh eth0
✅ 目标:
ethtool -c eth0
ethtool -C eth0 rx-usecs 50
ethtool -C eth0 tx-usecs 50
| 场景 | 建议 |
|---|---|
| 高吞吐 | 大 usecs |
| 低延迟 | 小 usecs / 关合并 |
| 交易系统 | rx-usecs 0 |
echo f > /sys/class/net/eth0/queues/rx-0/rps_cpus
echo 32768 > /proc/sys/net/core/rps_sock_flow_entries
echo 2048 > /sys/class/net/eth0/queues/rx-0/rps_flow_cnt
echo f > /sys/class/net/eth0/queues/tx-0/xps_cpus
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.core.netdev_max_backlog = 10000
net.core.somaxconn = 65535
isolcpus)iperf3 -c target
ping -i 0.01 target
ethtool -S eth0
mpstat -P ALL 1
网卡队列调优 = 队列数匹配 CPU + 中断均衡 + Ring buffer 防丢 + 延迟/吞吐权衡
如果你愿意,可以告诉我:
ethtool -i eth0)我可以直接给你一套可执行的调优命令。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。