网卡多队列

多队列指实例规格支持的最大网卡队列数。单个ECS实例vCPU处理网络中断存在性能瓶颈时,您可以将实例中的网络中断分散给不同的CPU处理。经测试,在相同的网络PPS和网络带宽的条件下,与1个队列相比,2个队列最多可提升性能达50%到100%,4个队列的性能提升更大。

在ECS实例上配置网卡多队列

如果您使用的镜像已默认开启网卡多队列功能,请跳过此章节内容。

本节以Aliyun Linux 17.1镜像为例,假设实例主网卡名称为eth0,辅助弹性网卡名称为eth1,介绍如何手动配置网卡多队列。

  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个队列
     
    说明 如果返回信息中,两个  Combined字段取值相同,则表示弹性网卡已开启支持多队列。
  2. 运行命令ethtool -L eth0 combined 2开启网卡的多队列功能。命令作用是设置主网卡eth0使用两个队列。
     
    [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个队列 # 设置辅助网卡eth1使用4个队列 [root@localhost ~]# ethtool -L eth1 combined 4
  4. (推荐)开启irqbalance服务,让ECS实例自动调整网络中断在多个vCPU核上的分配。
    1. 运行命令systemctl start irqbalance开启服务。
    2. 运行命令systemctl status irqbalance 查看服务状态。

      结果显示active (running),表示已开启irqbalance服务。

 
说明 开启网卡多队列后,如果网络性能提升仍达不到您的预期,您可以考虑开启RPS(Receive Packet Steering)特性。
阿里云官方提供的CentOS、Ubuntu公共镜像,默认开启RPS特性。如果您使用的是其他公共镜像或者自定义镜像,可参考如下Shell脚本自行开启RPS特性。
 
#!/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

猜你喜欢

转载自www.cnblogs.com/kcxg/p/10867745.html