单个CPU处理网络中断存在瓶颈,您可以将ECS实例中的网络中断分散给不同的CPU处理。经测试,在网络PPS和网络带宽的测试中,与1个队列相比,2个队列最多可提升性能达50%到1倍,4个队列的性能提升更大。
支持多队列的ECS实例规格
详见 实例规格族。
支持多队列的镜像
目前,由阿里云官方提供的系统镜像中,以下镜像支持多队列:
说明 镜像是否支持多队列与操作系统的位数无关。
系统镜像 | 是否支持多队列 | 是否默认开启多队列 |
---|---|---|
CentOS 6.8/6.9/7.2/7.3/7.4 | 是 | 是 |
Ubuntu 14.04/16.04/18.04 | 是 | 是 |
Debian 8.9/9.2 | 是 | 是 |
SUSE Linux Enterprise Server 12 SP1 | 是 | 是 |
SUSE Linux Enterprise Server 12 SP2 | 是 | 是 |
Red Hat Enterprise Linux 6.9/7.4/7.5 | 是 | 否 |
OpenSUSE 42.3 | 是 | 否 |
Aliyun Linux 17.1 | 是 | 否 |
Windows 2012 R2和Windows 2016 | 是 | 是 |
在ECS实例上配置网卡多队列
如果您使用的是默认开启网卡多队列功能的系统,无需配置。
本节介绍如何手动配置网卡多队列,以Aliyun Linux 17.1镜像为例,主网卡interface名称为eth0,辅助网卡为eth1。
-
运行命令 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个队列
说明 如果两个Combined
数值相同,则表示已开启支持多队列。 -
运行命令
ethtool -L eth0 combined 2
开启网卡的多队列功能。[root@localhost ~]# ethtool -L eth0 combined 2 # 设置eth0当前使用2个队列
-
设置辅助网卡的多队列。
[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个队列 [root@localhost ~]# ethtool -L eth1 combined 4 # 设置eth1当前使用4个队列
-
建议开启irqbalance服务,让系统自动调整网络中断在多个CPU核上的分配。
- 运行命令
systemctl start irqbalance
开启服务。 - 运行命令
systemctl status irqbalance
查看服务状态。结果显示active (running)
,表示服务已开启。
- 运行命令
-
开启多队列后,如果网络性能提升仍不如您的预期,您可以考虑开启RPS特性。阿里云官方提供的CentOS、Ubuntu系统镜像,默认开启RPS特性。如果您使用自定义镜像,可参考如下Shell脚本来配置:
#!/bin/bash cpu_num=$(grep -c processor /proc/cpuinfo) quotient=$((cpu_num/8)) if [ $quotient -gt 2 ]; then quotient=2 elif [ $quotient -lt 1 ]; then quotient=1 fi for i in $(seq $quotient) do cpuset="${cpuset}f" done for rps_file in $(ls /sys/class/net/eth*/queues/rx-*/rps_cpus) do echo $cpuset > $rps_file done