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 使用后台线程来服 ...
随机推荐
- xss中shellcode的调用
shellcode就是利用漏洞所执行的代码 在完整的xss攻击之中,会将shellcode存放在一定的地方,然后触发漏洞,引发shellcode. 1.远程调用执行js 可将js代码单独放在一个js文 ...
- 1. QCamera2基础组件——cam_semaphore
/* Copyright (c) 2012, The Linux Foundation. All rights reserved. * * Redistribution and use in sour ...
- Linux实战(20):非docker部署ELK
部署环境: Elasticsearch:7.5.2 Kibana:7.5.2 Logstash:7.5.2 filebeat:7.5.2 redis:最新版 部署方式:rpm+二进制包 使用架构 软件 ...
- Linux实战(4):Centos7升级python
记一笔升级python后产生的问题,并给予解决方案.莫慌看下文: 升级python3 我是直接 yum安装的,当然安装方法有很多,不喜欢此安装方式的可选用其他方式,我再此就不一一解释了.安装方式可不同 ...
- Shell编程(5)
文本处理三剑客 在 Shell 下使用这些正则表达式处理文本最多的命令有下面几个工具: 命令 描述 grep 默认不支持扩展表达式,加-E ...
- Java JVM参数在idea里面配置
找到你需要配置的启动类选择 接着点击Edit Configurations 在VM options里面配置就完成了
- UCanCode发布升级E-Form++可视化源码组件库2020全新版 !
2020年. 中国.成都 UCanCode发布升级E-Form++可视化源码组件库2020全新版 ! --- 全面性能提升,UCanCode有史以来最强大的版本发布! E-Form++可视化源码组件库 ...
- PostgreSQL数组类型应用
在使用 awk 脚本:数组是一大利器:在很多场景是用数组能处理. 在 python 中,数据类型list:相当于array类型. 在 Oracle 中,对 array 不够友好,感觉像是鸡肋.但是在 ...
- Linux初步了解
文件系统类型:swap分区:用于内存扩充,用磁盘兑换,磁盘是内存的两倍,便于替换 / 分区:容纳根文件系统 文件名:由字母,数字,下划线,圆点组成 文件类型:显示在每一行的左边第一个字符 普通文件 ...
- gRPC-Protocol语法指南
语法指南 (proto3) Defining A Message Type Scalar Value Types Default Values Enumerations Using Other Mes ...