File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -364,17 +364,21 @@ Redis 通过 **IO 多路复用程序** 来监听来自客户端的大量连接
364364
365365虽然,Redis6.0 引入了多线程,但是 Redis 的多线程只是在网络数据的读写这类耗时操作上使用了,执行命令仍然是单线程顺序执行。因此,你也不需要担心线程安全问题。
366366
367- Redis6.0 的多线程默认是禁用的,只使用主线程。如需开启需要修改 redis 配置文件 ` redis.conf ` :
367+ Redis6.0 的多线程默认是禁用的,只使用主线程。如需开启需要设置IO线程数 > 1,需要修改 redis 配置文件 ` redis.conf ` :
368368
369369``` bash
370- io-threads-do-reads yes
370+ io-threads 4 # 设置1的话只会开启主线程,官网建议4核的机器建议设置为2或3个线程,8核的建议设置为6个线程
371371```
372+ 另外:
373+ - io-threads的个数一旦设置,不能通过config动态设置
374+ - 当设置ssl后,io-threads将不工作
372375
373- 开启多线程后,还需要设置线程数,否则是不生效的。 同样需要修改 redis 配置文件 ` redis.conf ` :
376+ 开启多线程后,默认只会使用多线程进行IO写入writes,即发送数据给客户端,如果需要开启多线程IO读取reads, 同样需要修改 redis 配置文件 ` redis.conf ` :
374377
375378``` bash
376- io-threads 4 # 官网建议4核的机器建议设置为2或3个线程,8核的建议设置为6个线程
379+ io-threads-do-reads yes
377380```
381+ 但是官网描述开启多线程读并不能有太大提升,因此一般情况下并不建议开启
378382
379383相关阅读:
380384
You can’t perform that action at this time.
0 commit comments