centos8平台:redis6配置启用io多线程(redis6.0.1)
一,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)的更多相关文章
- 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 ...
- centos8平台安装redis6.0.1
一,redis的官网: https://redis.io/ redis6于5月3日正式发布,它的新增功能: acl 多线程io cluster proxy resp3协议 本文演示redis6.0.1 ...
- 微信公众平台——基础配置——服务器配置:PHP版
在自己的服务器上新建一个空白php文件,输入以下任一版本的代码,如下: 版本一: <?php $token = "dige1994"; $signature = $_GET[ ...
- CentOS8.0-1905安装配置ftp服务器
关键词:CentOS8/RHEL8;安装配置FTP/安装配置VSFTPD;被动模式/PASV##CentOS8.0-1905发布后,尝试将FTP服务器迁移至新版本的CentOS中,但是测试过程中,在防 ...
- centos8平台使用ip命令代替ifconfig管理网络
一,为什么建议使用ip命令代替ifconfig? 1,ifconfig所属的net-tools包已经不再被维护了 虽然可以用,但会发生看不到部分ip等情况, [root@centos8 liuhong ...
- centos8平台使用dnf/yum管理软件包
一,dnf的用途 centos7开始,DNF 成为了默认的软件包管理器,同时 yum 仍然是可用的 DNF包管理器克服了YUM包管理器的一些瓶颈,提升了用户体验,内存占用,依赖分析,运行速度等方面 D ...
- 美图WEB开放平台环境配置
平台环境配置 1.1.设置crossdomain.xml 下载crossdomain.xml文件,把解压出来的crossdomain.xml文件放在您保存图片或图片来源的服务器根目录下,比如: htt ...
- 第二步 在D2RQ平台上配置jena环境
第二步 在D2RQ平台上配置jena环境 2013年10月16日 9:48:53 搞了这么长时间语义,只用过protege这样的工具,一直没有落实到实际代码上.jena也看过好久了,总认为是hp公司的 ...
- 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 使用后台线程来服 ...
随机推荐
- 【吴恩达课程使用】keras cpu版安装【接】- anaconda (python 3.7) win10安装 tensorflow 1.8 cpu版
一.确认tensorflow的版本: 接上一条tensorflow的安装,注意版本不匹配会出现很多问题!:[吴恩达课程使用]anaconda (python 3.7) win10安装 tensorfl ...
- IDEA使用 live template添加groovy脚本给方法,类,js方法添加注释(转载)
IDEA添加Live Template: File->Setting->Editor->Live Templates Abbreviation: * Template text: * ...
- hystrix源码小贴士之之hystrix-metrics-event-stream
hystrix-metrics-event-stream主要提供了一些servlet,可以让用户通过http请求获取metrics信息. HystrixSampleSseServlet 继承了Http ...
- 【机器学习】梯度下降 II
Gradient Descent 梯度下降 II 关于 Gradient Descent 的直观解释,参考上一篇博客[机器学习]梯度下降 I 本模块介绍几种梯度下降模型.定义符号标记如下: \(\th ...
- TB级倾斜模型加载速度太慢?这是我见过最快的加载方式没有之一
随着无人机性能快速提升,单个项目涉及到的倾斜摄影模型数据范围.数据量及单个模型体积也在不断变大,带来的问题是数据显示速度却越来越慢,那么如何在不升级配置的情况下提升模型的加载速度呢? TB级倾斜摄 ...
- Flutter音频播放--chewie_player的基本使用
发现网络似乎没有关于简单音频播放的插件介绍,这几天找了一下,结果也都不尽人意,最后也是debug一下chewie_player插件的官方demo 先上官方demo图 官方git地址:https://g ...
- 目标检测:SSD算法详解
一些概念 True Predict True postive False postive 预测为正类 False negivate True negivate 预测为负类 真实为 ...
- 主键生成器效率提升方案|基于雪花算法和Redis控制进程隔离
背景 主键生成效率用数据库自增效率也是比较高的,为什么要用主键生成器呢?是因为需要insert主表和明细表时,明细表有个字段是主表的主键作为关联.所以就需要先生成主键填好主表明细表的信息后再一次过在一 ...
- P3431 [POI2005]AUT-The Bus
Link 简化题意: 给你一张网格图,每个点有其对应的权值,让你找出来一条横纵坐标都单调不降的路径,并最大化经过点的权值. 分析: 这是经典的二维数点或者二维偏序问题. 如果两维一直在变的话,我们不是 ...
- CF149D Coloring Brackets
CF149D Coloring Brackets Link 题面: 给出一个配对的括号序列(如"\((())()\)"."\(()\)"等, "\() ...