首页 > 数据库 >redis: 开启io多线程

redis: 开启io多线程

时间:2024-09-30 16:13:50浏览次数:1  
标签:web io redis server threads conf 多线程

一,配置redis.conf

[root@web conf]# vi redis.conf 

修改两个参数

# 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. In order to
# enable I/O threads use the following configuration directive:
#
# io-threads 4
io-threads 4
#
# Setting io-threads to 1 will just use the main thread as usual.
# 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:
#
# io-threads-do-reads no
io-threads-do-reads yes

 

二,查看线程数量

启用io多线程前:

[root@web conf]# pstree -p 1569680
redis-server(1569680)─┬─{redis-server}(1569681)
                      ├─{redis-server}(1569682)
                      ├─{redis-server}(1569683)
                      ├─{redis-server}(1569684)
                      └─{redis-server}(1569693)

启用io多线程后:

[root@web conf]# pstree -p 2315378
redis-server(2315378)─┬─{redis-server}(2315380)
                      ├─{redis-server}(2315381)
                      ├─{redis-server}(2315382)
                      ├─{redis-server}(2315383)
                      ├─{redis-server}(2315384)
                      ├─{redis-server}(2315385)
                      └─{redis-server}(2315386)

增加了2个线程,推测有线程是和原来其他的复用,所以没有增加3个

三,从客户端查看配置

修改配置前:

[root@web conf]# redis-cli
127.0.0.1:6379> CONFIG GET * 
253) "io-threads-do-reads"
254) "no"
...
317) "io-threads"
318) "1" 

修改配置后:

[root@web conf]# redis-cli
127.0.0.1:6379> CONFIG GET * 
...
163) "io-threads"
164) "4" 
...
297) "io-threads-do-reads"
298) "yes" 

 

标签:web,io,redis,server,threads,conf,多线程
From: https://www.cnblogs.com/architectforest/p/18442021

相关文章

  • 章19——IO流
    文件流的概念常用的文件操作常用目录操作删除文件前应先判断文件是否存在以免出错。file.delete也会返回一个布尔值表示是否删除成功。同样适用于创建目录,file.mkdirs(),file.mkdir();多级目录不可以用file.mkdir()。IO流原理以及流的分类放在IO包下面:常用的类......
  • Spring boot中使用实现Redis Lua计数器
    Springboot中使用实现RedisLua计数器在SpringBoot中使用RedisLua脚本实现计数器,可以通过以下步骤来完成。这个示例将展示如何使用Lua脚本在Redis中安全地增加计数器的值。步骤1:添加依赖首先,确保你的pom.xml文件中包含了SpringDataRedis和Lettuce的依赖:<dependency>......
  • Redis 中Lua脚本的使用
    Redis中Lua脚本的使用Redis支持使用Lua脚本来执行原子操作,以下是一个简单的RedisLua脚本示例以及如何在Redis中使用它。示例:计数器这个脚本会增加一个指定键的计数器,并返回新的计数值。--increase_counter.lualocalkey=KEYS[1]--第一个参数是键localincrem......
  • 【多线程】多线程(1):概念,创建线程
    【多线程的概念】之前写过的所有代码,都只能使用“一个核心”,此时无论如何优化代码,最多只能用一个cpu核心,把这个核心跑满了,其他核心也是空闲着,通过写特殊的代码,把多个cpu核心都能应用起来,此为“并发编程”之前使用的并发模式为“多进程编程”,其在创建/销毁进程时开销较大,一旦......
  • 驱动更新 IObit Driver Booster PRO v12.0.0.354 绿色版
    驱动更新IObitDriverBoosterPROv12.0.0.354绿色版下载地址:https://pan.quark.cn/s/85f9c35e7944介绍IObitDriverBooster,全球专业级驱动更新软件。检测硬件驱动更新、驱动备份管理、支持离线驱动更新,检测游戏组件、修复设备错误、无声问题、网络问题。提供游戏加速、......
  • SciTech-Automation-UI交互自动化: Microsoft 的 接口自动化测试 : 微信的: LLM(AI/Tr
    用LLM+Python实现微信消息的自动应答!/usr/bin/python3#coding:utf-8importpandasaspdimportnumpyasnpfromuiautomationimportwindowControl,Menucontrolfromfunctoolsimportpartial,wraps#readreplydatadf=pd.read_csv("应答数据.csv",......
  • label-studio的简单使用
    人工标注一、语义角色:Agent:实施动作的主体Action:谓语,动作Patient:承受动作的客体Time:发生动作的时间Location:发生动作的地点二、工具——labelstudio官方网址:OpenSourceDataLabeling|LabelStudio使用工具:labelstudio安装命令:pipinstalllabel-studio启动命令:label-studio访......
  • Redis缓存穿透解决方案之一:布隆过滤器与计数型布隆过滤器概述以及两者在Spring中的使
    布隆过滤器(BloomFilter)和计数型布隆过滤器(CountingBloomFilter)都是高效的概率性数据结构,用于判断某个元素是否在集合中。它们的设计目标是降低内存开销,通过多个哈希函数与位数组的组合,实现快速查询,但允许一定的误判率。文章目录1.布隆过滤器(BloomFilter)1.1原理1.2......
  • Spring Boot项目 application.yml 配置赋值到 Java配置类中
    SpringBoot项目 application.yml 配置赋值到Java配置类中application.ymlsdkConfig:#是否为测试环境(true=是;false=否)isDevEnv:falseSdkConfig.javaimportorg.springframework.beans.factory.annotation.Value;importorg.springframework.stereotype.Comp......
  • 实战 vSphere 7 vMotion 迁移说明 ( Vcenetr 内迁移、 跨vcenter 迁移)
    目录一、vMotion简介二、Vcenter内虚拟机迁移2.1无共享存储的环境中的vMotion具有以下要求和限制2.2网卡启用vMotion​编辑2.3右键单击虚拟机,然后选择迁移2.4选择更改计算资源和存储2.5选择虚拟机的目标资源2.6选择虚拟机磁盘格式2.7选择虚拟机存储策略2.......