1、Broadcom的网卡建议关闭GRO功能

ethtool-K eth0 gro off
ethtool-K eth1 gro off
ethtool-K eth2 gro off
ethtool-K eth3 gro off

2、关闭irqbalance服务并手动分配网卡中断

service irqbalance stop
chkconfig irqbalance off

# 查看网卡中断号

grepethx /proc/interrupts

# 分配到每颗颗CPU核上

cat/proc/irq/{84,85,86,87,88,89,90,91,92,93}/smp_affinity(下面echo的值从此获取)
echo1 > /proc/irq/84/smp_affinity
echo2 > /proc/irq/85/smp_affinity
echo4 > /proc/irq/86/smp_affinity
echo8 > /proc/irq/87/smp_affinity
echo10 > /proc/irq/88/smp_affinity
echo20 > /proc/irq/89/smp_affinity
echo40 > /proc/irq/90/smp_affinity
echo80 > /proc/irq/91/smp_affinity
echo100 > /proc/irq/92/smp_affinity
echo200 > /proc/irq/93/smp_affinity

3、开启网卡的RPS功能 (Linux内核2.6.38或以上版本支持)

# Enable RPS (Receive Packet Steering)
rfc=4096
cc=$(grep-c processor /proc/cpuinfo)
rsfe=$(echo$cc*$rfc | bc)
sysctl -w net.core.rps_sock_flow_entries=$rsfe
forfileRps in$(ls/sys/class/net/eth*/queues/rx-*/rps_cpus)
do
echofff > $fileRps
done
forfileRfc in$(ls/sys/class/net/eth*/queues/rx-*/rps_flow_cnt)
do
echo$rfc > $fileRfc
done
tail/sys/class/net/eth*/queues/rx-*/{rps_cpus,rps_flow_cnt}

献上一个完整的脚本:

vi/opt/sbin/change_irq.sh
#!/bin/bash
ethtool-K eth0 gro off
ethtool-K eth1 gro off
ethtool-K eth2 gro off
ethtool-K eth3 gro off
service irqbalance stop
chkconfig irqbalance off
cat/proc/irq/{84,85,86,87,88,89,90,91,92,93}/smp_affinity
echo1 > /proc/irq/84/smp_affinity
echo2 > /proc/irq/85/smp_affinity
echo4 > /proc/irq/86/smp_affinity
echo8 > /proc/irq/87/smp_affinity
echo10 > /proc/irq/88/smp_affinity
echo20 > /proc/irq/89/smp_affinity
echo40 > /proc/irq/90/smp_affinity
echo80 > /proc/irq/91/smp_affinity
echo100 > /proc/irq/92/smp_affinity
echo200 > /proc/irq/93/smp_affinity
# Enable RPS (Receive Packet Steering)
rfc=4096
cc=$(grep-c processor /proc/cpuinfo)
rsfe=$(echo$cc*$rfc | bc)
sysctl -w net.core.rps_sock_flow_entries=$rsfe
forfileRps in$(ls/sys/class/net/eth*/queues/rx-*/rps_cpus)
do
echofff > $fileRps
done
forfileRfc in$(ls/sys/class/net/eth*/queues/rx-*/rps_flow_cnt)
do
echo$rfc > $fileRfc
done
tail/sys/class/net/eth*/queues/rx-*/{rps_cpus,rps_flow_cnt}
chmod+x /opt/sbin/change_irq.sh
echo"/opt/sbin/change_irq.sh">> /etc/rc.local

PS:记得修改网卡中断号,别直接拿来用哦