Redis调优之指定CPU(亲和力)以及软中断

来源:互联网 发布:免费杀毒软件知乎 编辑:程序博客网 时间:2024/05/01 01:08

指定CPU

为什么这么做?

由于redis是单进程服务,一个redis服务进程只会使用一个内核,所以在部署redis服务的时候最好对redis进程指定CPU。

如何做?

taskset是LINUX提供的一个命令,可以让某个程序运行在某个(或)某些CPU上。

1)显示进程运行的CPU

命令taskset -p 21184

显示结果:

pid 21184's current affinity mask: ffffff

注:21184是redis-server运行的pid

      显示结果的ffffff实际上是二进制24个低位均为1的bitmask,每一个1对应于1个CPU,表示该进程在24个CPU上运行

2)指定进程运行在某个特定的CPU上

命令taskset -pc 3 21184

显示结果:

pid 21184's current affinity list: 0-23
pid 21184's new affinity list: 3

注:3表示CPU将只会运行在第4个CPU上(从0开始计数)。http://write.blog.csdn.NET/postedit?ticket=ST-133194-dCdOr36vRfv7GrhbyGZf-passport.csdn.Net

3)进程启动时指定CPU

命令taskset -c 1 ./redis-server ../redis.conf

 

结合这上边三个例子,再看下taskset的manual,就比较清楚了。

OPTIONS
-p, --pid
operate on an existing PID and not launch a new task

-c, --cpu-list
specify a numerical list of processors instead of a bitmask. The list may contain multiple items, separated by comma, and ranges. For example, 0,5,7,9-11.

原文地址:http://blog.csdn.net/liu_zhuang_love/article/details/51649032


软中断

redis和软中断所使用的cpu分离开,可以很有效的提升redis的吞吐量。

参考:

http://www.th7.cn/db/nosql/201701/224080.shtml

http://blog.csdn.net/slim68/article/details/54583633

http://blog.csdn.net/houjixin/article/details/47420479

0 0
原创粉丝点击