云服务器网络性能影响因素分析
对网络的性能和常见问题,分享下经历过的问题和经验。获取网卡目前我们在公有云上买到的服务器,一般网卡类型都是virtio,这个可以通过ethtool -i eth1获取。[root@VM_52_246_centos:~]# ethtool -i eth1driver: virtio_netversion: 1.0.0firmware-version:bus-info: 0000:00:03.0supports-statistics: nosupports-test: nosupports-eeprom-access: nosupports-register-dump: nosupports-priv-flags: novirtio网卡的性能一部分是网卡本身性能,除了各个厂商底层实现的限制外,还有以下我们可控的因素。队列数[root@VM_52_246_centos:~]# ethtool -l eth1Channel parameters for eth1:Pre-set maximums:RX: 0TX: 0Other: 0Combined: 2Current hardware settings:RX: 0TX: 0Other: 0Combined: 2该参数一般系统规格有关。队列数不少于cpu数时性能最高,但在队列数大于16之后,性能提升不会那么明显了。队列长度[root@VM_52_246_centos:~]# ethtool -g eth1Ring parameters for eth1:Pre-set maximums:RX: 256RX Mini: 0RX Jumbo: 0TX: 256Current hardware settings:RX: 256RX Mini: 0RX Jumbo: 0TX: 256这个参数一般出厂会设置为最优。我们如果突发流量不大,有时也可以手动调小,这样pps会更高,缓存亲和性会更好。如果突发流量大,那么最好保持最大值。网卡中断绑定查看网卡队列的中断[root@VM_52_246_centos:~]# cat /proc/interrupts | grep virtio | grep

input45: 3038319 0 0 0 0 0 0 0 PCI-MSI-edge virtio0-input.047: 1 2032771 0 0 0 0 0 0 PCI-MSI-edge virtio0-input.1查看中断亲和性[root@VM_52_246_centos:~]# cat /proc/irq/45/smp_affinity[root@VM_52_246_centos:~]# cat /proc/irq/47/smp_affinity从结果看,是绑定到了不同的cpu。这样性能比较高。网卡RPS设置[root@VM_52_246_centos:~]# cat /sys/class/net/eth1/queues/rx-0/rps_cpus[root@VM_52_246_centos:~]# cat /sys/class/net/eth1/queues/rx-1/rps_cpus在cpu数大于队列数的情况下,开启rps会得到更好的网络性能。这里表示,2个队列,收包软中断会重分发到8个cpu上。以上是使用公有云服务器,通用的一些设置检查,也是影响virtio网络性能的关键因素。对于不在意成本的用户,可以买到独享服务器,设置裸金属服务器,这种情况下,网络性能会更好。
转载于天翼云,如有侵权,请联系删除,谢谢