一,linux平台上redis6的安装

请参见这一篇:

https://www.cnblogs.com/architectforest/p/12830056.html

说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest

对应的源码可以访问这里获取: https://github.com/liuhongdi/

说明:作者:刘宏缔 邮箱: 371125307@qq.com

二,使用redis6的io多线程的好处?

1,reddis6把多线程用在哪里?

redis运行的瓶颈,通常不在cpu,而在内存和网络I/O

Redis 6 对多线程的启用,主要用在处理网络I/O,

流程就是:把监听到的网络的事件,分发给work thread做处理,

在处理完之后,由主线程负责执行。

说明:这是我们要注意的地方:

redis6对于命令的执行仍然是由主线程执行,

也就是象以前使用的原子性的命令如rpush/lua脚本仍然具有原子性,

不会因为多线程的引入也失效。

2,性能提升显著:

Redis读写网络的 read/write 系统调用在 执行期间占用了大部分 CPU 时间,

所以把网络读写做成多线程的方式对性能会有很大提升,

根据测试,在 4个线程 IO 时,性能相比单线程提高一倍,

是redis6中的最可观的性能提升

三,如何启用redis6的io多线程

1,什么情况适宜启用io多线程?

来自官方配置文件的说明:

默认情况多线程是disabled,当server有至少4个核心或更多时可以启用,

至少留下一个备用的核心。

当设置为多于8个线程时,不会用明显的性能提升

建议当确实遇到性能问题时而且redis的实例能占用cpu时间的一大部分时

再启用threaded I/O,这样会比较有效,

否则没有启用这个功能的必要。

原说明:

# By default threading is disabled, we suggest enabling it only in machines
# that have at least 4 or more cores, leaving at least one spare core.
# Using more than 8 threads is unlikely to help much. We also recommend using
# threaded I/O only if you actually have performance problems, with Redis
# instances being able to use a quite big percentage of CPU time, otherwise
# there is no point in using this feature.

2,编辑redis的配置文件

[root@centos8 conf]# vi /usr/local/soft/redis6/conf/redis.conf 

配置指令一

#io-threads: 启用的io线程数量

io-threads 4

这个值设置为多少?

根据配置文件的说明:

如果你的server有4个核心,尝试把这个值设置为3

如果有8个核心,尝试把这个值设置为6

但这个值不建议超过8

附原说明:

# So for instance if you have a four cores boxes, try to use 2 or 3 I/O
# threads, if you have a 8 cores, try to use 6 threads

配置指令二:

#读请求也使用io线程

io-threads-do-reads yes

设置为yes即可

配置文件中的说明:

当I/O threads被启用时,线程仅用于写,

如果需要把读数据和协议解析也启用线程,

则需要把io-threads-do-reads也设置为yes

作者认为对读请求启用io-threads得到的帮助不算太多

原说明:

# When I/O threads are enabled, we only use threads for writes, that is
# to thread the write(2) syscall and transfer the client buffers to the
# socket. However it is also possible to enable threading of reads and
# protocol parsing using the following configuration directive, by setting
# it to yes:
# Usually threading reads doesn't help much

四,多线程使用中需要注意的两点

1,在redis运行时通过config set 来使用线程的配置指令不会生效,

当SSL启用时,多线程也不会生效

原说明:

# NOTE 1: This configuration directive cannot be changed at runtime via
# CONFIG SET. Aso this feature currently does not work when SSL is
# enabled.

2,如果使用redis-benchmark测试redis的速度 ,

需要确认redis-benchmark是多线程模式,

使用 --threads选项来匹配redis的线程数量,

否则不会看到性能有明显提升

原说明:

# NOTE 2: If you want to test the Redis speedup using redis-benchmark, make
# sure you also run the benchmark itself in threaded mode, using the
# --threads option to match the number of Redis theads, otherwise you'll not
# be able to notice the improvements.

五,比较启用线程前和启用线程后的线程数量

启用前:包括主线程:共5个线程

[root@centos8 conf]# pstree -p 3882
redis-server(3882)─┬─{redis-server}(3883)
├─{redis-server}(3884)
├─{redis-server}(3885)
└─{redis-server}(3886)

我们把线程数量设置为4,重启redis6的服务

启用后:包括主线程:共8个线程

[root@centos8 conf]# pstree -p 3623
redis-server(3623)─┬─{redis-server}(3624)
├─{redis-server}(3625)
├─{redis-server}(3626)
├─{redis-server}(3627)
├─{redis-server}(3628)
├─{redis-server}(3629)
└─{redis-server}(3630)

看来之前做网络io处理的只有一个线程,

调整为4之后,增加了3个线程,共4个线程

六,查看redis的版本

[root@centos8 bin]# /usr/local/soft/redis6/bin/redis-server --version
Redis server v=6.0.1 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=0

七,查看centos的版本

[root@centos8 bin]# cat /etc/redhat-release
CentOS Linux release 8.1.1911 (Core)

centos8平台:redis6配置启用io多线程(redis6.0.1)的更多相关文章

  1. centos8平台redis cluster集群搭建(redis5.0.7)

    一,规划 redis cluster 1,cluster采用六台redis,3主3从 redis1    : ip: 172.17.0.2 redis2    : ip: 172.17.0.3 red ...

  2. centos8平台安装redis6.0.1

    一,redis的官网: https://redis.io/ redis6于5月3日正式发布,它的新增功能: acl 多线程io cluster proxy resp3协议 本文演示redis6.0.1 ...

  3. 微信公众平台——基础配置——服务器配置:PHP版

    在自己的服务器上新建一个空白php文件,输入以下任一版本的代码,如下: 版本一: <?php $token = "dige1994"; $signature = $_GET[ ...

  4. CentOS8.0-1905安装配置ftp服务器

    关键词:CentOS8/RHEL8;安装配置FTP/安装配置VSFTPD;被动模式/PASV##CentOS8.0-1905发布后,尝试将FTP服务器迁移至新版本的CentOS中,但是测试过程中,在防 ...

  5. centos8平台使用ip命令代替ifconfig管理网络

    一,为什么建议使用ip命令代替ifconfig? 1,ifconfig所属的net-tools包已经不再被维护了 虽然可以用,但会发生看不到部分ip等情况, [root@centos8 liuhong ...

  6. centos8平台使用dnf/yum管理软件包

    一,dnf的用途 centos7开始,DNF 成为了默认的软件包管理器,同时 yum 仍然是可用的 DNF包管理器克服了YUM包管理器的一些瓶颈,提升了用户体验,内存占用,依赖分析,运行速度等方面 D ...

  7. 美图WEB开放平台环境配置

    平台环境配置 1.1.设置crossdomain.xml 下载crossdomain.xml文件,把解压出来的crossdomain.xml文件放在您保存图片或图片来源的服务器根目录下,比如: htt ...

  8. 第二步 在D2RQ平台上配置jena环境

    第二步 在D2RQ平台上配置jena环境 2013年10月16日 9:48:53 搞了这么长时间语义,只用过protege这样的工具,一直没有落实到实际代码上.jena也看过好久了,总认为是hp公司的 ...

  9. 14.6.7 Configuring the Number of Background InnoDB IO Threads 配置InnoDB IO Threads的数量

    14.6.7 Configuring the Number of Background InnoDB IO Threads 配置InnoDB IO Threads的数量 InnoDB 使用后台线程来服 ...

随机推荐

  1. python调用接口——requests模块

    前提:安装pip install requests 导入import requests 1.get请求   result=requests.get(url,d).json()  或  .text 2. ...

  2. NSThread线程对象

    NSThread 创建线程的方式 准备在后台线程调用的方法 longOperation: - (void)longOperation:(id)obj { NSLog(@"%@ - %@&qu ...

  3. 教你一招Linux下文本比对方法

    我们在写代码的过程中,免不了会对代码进行一些修修改改.但经常会出现改着改着,就不知道改完后与源文件的差异是怎样的.这里,我们就需要一个文本比对工具来进行文本比对. 有经验的程序员都知道,Windows ...

  4. [程序员代码面试指南]最长递增子序列(二分,DP)

    题目 例:arr=[2,1,5,3,6,4,8,9,7] ,最长递增子序列为1,3,4,8,9 题解 step1:找最长连续子序列长度 dp[]存以arr[i]结尾的情况下,arr[0..i]中的最长 ...

  5. spring framework源码之AnnotationConfigApplicationContext

    AnnotationConfigApplicationContext 内部使用了AnnotatedBeanDefinitionReader:ClassPathBeanDefinitionScanner ...

  6. 人工智能顶级会议最佳论文里的“DaDianNao”是什么鬼?

    最近对人工智能领域的 AI 加速芯片感兴趣,在翻阅 Google 的第一代 TPU 论文时,在相关工作中看到了 DaDianNao,PuDianNao,ShiDianNao.看的我一脸懵逼,这是什么? ...

  7. elasticsearch备份和还原(基于hdfs)

    备份和还原,为什么elasticsearch还需要备份呢,明明可以设置副本做到高可用,那怕啥呢? 其实在实际的生产环境中,一般最终的结果数据都是要备份的,这样的做的目的,就是能够以最快的速度还原数据, ...

  8. 搭建ssm整合

    一.导入依赖 二.新建java和resources目录 1.在java目录新建cn.itcat.domain包,继续添加controller,service,dao,的包 2.在domain里面创建A ...

  9. git 一个可以提高开发效率的命令:cherry-pick

    各位码农朋友们一定有碰到过这样的情况:在develop分支上辛辛苦苦撸了一通代码后开发出功能模块A,B,C,这时老板过来说,年青人,我们现在先上线功能模块A,B.你一定心里一万只草泥马奔腾而过,但为了 ...

  10. 关于VS编译报错,但是错误信息未提示问题解决方案

    可能代码中引用了别的类库中的函数,然后未编译被引用库导致编译报错,重新编译被引用库然后再编译当前库即可解决问题