Redis THREADED I/O(配置翻译)

把redis.conf里面的内容翻译了一下

标题:THREADED I/O
Redis is mostly single threaded, however there are certain threaded operations such as UNLINK, slow I/O accesses and other things that are performed on side threads.

翻译:
Redis总体上是单线程的,但是也有一些特定的场景用多线程,比如unlink key、flushdb async、flushall async等等。还有其他的一些事情是交给额外的线程去做的。

Now it is also possible to handle Redis clients socket reads and writes in different I/O threads. Since especially writing is so slow, normally Redis users use pipelining in order to speed up the Redis performances per core, and spawn multiple instances in order to scale more. Using I/O threads it is possible to easily speedup two times Redis without resorting to pipelining nor sharding of the instance.

翻译:
现在Redis的客户端读写操作也可以用不同的I/O线程处理。特别是因为写操作很慢,通常用户会用pipeline来提升单核下的Redis性能,并且运行多个Redis的实例来实现扩展。使用多线程I/O,不需要使用pipeline和数据分片,就可以轻松提升两倍性能。

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.

翻译:
默认情况下,多线程I/O是禁用的。但是只有在4核以上的机器开启才有意义。配置的线程数量不要超过8个,多了起不到什么作用。而且,最好是确实遇到了性能问题,比如在Redis已经占用了CPU的大部分时间的情况下,才使用多线程I/O的功能,不然的话开启这个功能也没什么懒用。

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:

翻译:
比如,如果你的机器是4核的,可以配置2个或者3个线程。如果你有8核,可以配置6个线程。通过下面这个参数来配置线程数:
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的值是1,跟只用main线程没什么区别。开启了多线程I/O,也就是为了让write这样的系统调用和传输客户端缓冲变成多线程的。当然,也可以把read操作和协议解析变成多线程的,只需要把下面这个参数配置成yes:
io-threads-do-reads yes

Usually threading reads doesn’t help much.
通常情况下多线程的read没什么懒用。

NOTE 1: This configuration directive cannot be changed at runtime via CONFIG SET. Aso this feature currently does not work when SSL is enabled.

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 threads, otherwise you’ll not be able to notice the improvements.

注意2点:
1、这两个配置是不能在运行时通过config set改变的。而且SSL功能启用的时候,多线程I/O也不会生效。
2、如果你想用benchmark脚本测试多线程下的性能提升,确保benchmark也是多线程模式,在后面加上--threads参数,来匹配Redis的线程数。不然看不到什么性能提升。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值