官方FAQ表示,由于Redis是基于内存的操做,CPU不是Redis的瓶颈,Redis的瓶颈最有多是机器内存的大小或者网络带宽。既然单线程容易实现,并且CPU不会成为瓶颈,那就瓜熟蒂落地采用单线程的方案了redis
It's not very frequent that CPU becomes your bottleneck with Redis, as usually Redis is either memory or network bound. For instance, using pipelining Redis running on an average Linux system can deliver even 1 million requests per second, so if your application mainly uses O(N) or O(log(N)) commands, it is hardly going to use too much CPU.网络
However, to maximize CPU usage you can start multiple instances of Redis in the same box and treat them as different servers. At some point a single box may not be enough anyway, so if you want to use multiple CPUs you can start thinking of some way to shard earlier.多线程
You can find more information about using multiple Redis instances in the Partitioning page.app
However with Redis 4.0 we started to make Redis more threaded. For now this is limited to deleting objects in the background, and to blocking commands implemented via Redis modules. For the next releases, the plan is to make Redis more and more threaded.性能
正是因为在单线程模式的状况下已经很快了,就没有必要在使用多线程了!可是,咱们使用单线程的方式是没法发挥多核CPU 性能,不过咱们能够经过在单机开多个Redis 实例来完善!this
警告1:这里咱们一直在强调的单线程,只是在处理咱们的网络请求的时候只有一个线程来处理,一个正式的Redis Server运行的时候确定是不止一个线程的,这里须要你们明确的注意一下!spa
警告2:在上图中FAQ中的最后一段,表述了从Redis 4.0版本开始会支持多线程的方式,可是,只是在某一些操做上进行多线程的操做!因此该篇文章在之后的版本中是否仍是单线程的方式须要读者考证!.net