Redis usually runs as a single process daemon that is the perfect sample of UNIX philosophy — one process just do one thing. But current servers have many CPUs(Cores) so we need to launch many Redis processes to provide service. After running multi-process redis-server in server, I found out there always be one redis-server daemon cost more CPU than others in “top” command:
I used perf to collect function samples in different processes and be noticed that some “softirq” function had been called. Then I remember I haven’t balance the soft-irq of netowork card into different CPU cores. After running my script to balance the soft-irq:
irqs=`cat /proc/interrupts |grep eth.*Tx|awk -F: '{print $1}'` core=1 for i in $irqs; do affinity=`echo "obase=16; $core" | bc` echo $affinity > /proc/irq/${i}/smp_affinity core=`expr $core \* 2` done
The view of “top” command looks much better now:
But I still have a question: why the “top” command count the CPU usage of system soft-irq into a innocent process? The answer is here: The soft-irq is run under process-context, so it certainly need to find a “scapegoat” process to count the CPU usage.