一,配置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