网卡多队列是一种技术手段,可以解决网络I/O带宽QoS(Quality of Service)问题。网卡多队列驱动将各个队列通过中断绑定到不同的核上,从而解决网络I/O带宽升高时单核CPU的处理瓶颈,提升网络PPS和带宽性能。经测试,在相同的网络PPS和网络带宽的条件下,与1个队列相比,2个队列最多可提升性能达50%到100%,4个队列的性能提升更大。
如何配置网卡多队列呢?
1) ethtool -l eth0查看网卡是否支持多队列:
[root@localhost ~]# ethtool -l eth0
Channel parameters for eth0:
Pre-set maximums:
RX: 0
TX: 0
Other: 0
Combined: 2 # 表示最多支持设置2个队列
Current hardware settings:
RX: 0
TX: 0
Other: 0
Combined: 1 # 表示当前生效的是1个队列
2) 运行ethtool -L eth0 combined 2命令开启网卡的多队列功能。
[root@localhost ~]# ethtool -L eth0 combined 2
3) 设置辅助网卡的多队列。
# 查看辅助网卡eth1支持多队列的情况
[root@localhost ~]# ethtool -l eth1
Channel parameters for eth1:
Pre-set maximums:
RX: 0
TX: 0
Other: 0
Combined: 4 # 表示最多支持设置4个队列
Current hardware settings:
RX: 0
TX: 0
Other: 0
Combined: 1 # 表示当前生效的是1个队列
4) 设置辅助网卡eth1使用4个队列
[root@localhost ~]# ethtool -L eth1 combined 4
OpenStack支持配置网卡多队列
要求内核版本大于3.0,配置方法如下:
glance image-update --property hw_vif_multiqueue_enabled=true ${IMAGE_ID}
队列长度固定为虚拟机的核数。
创建虚拟机查看网卡信息:
# ethtool -l eth0
Channel parameters for eth0:
Pre-set maximums:
RX: 0
TX: 0
Other: 0
Combined: 2
Current hardware settings:
RX: 0
TX: 0
Other: 0
Combined: 1
网卡信息表明支持的最大队列(Combined)为2,目前设置为1,可以通过ethtool工具修改配置:
ethtool -L eth0 combined 2
为了保证中断自动均衡到所有的CPU,建议开启irqbalance服务:
systemctl enable irqbalance
systemctl start irqbalance
参考资料
网友评论