多核CPU上的Redis性能 [英] Redis performance on a multi core CPU

查看:550
本文介绍了多核CPU上的Redis性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在四处查看redis,以便为我提供一个中间高速缓存存储,其中包含有关交集和并集等集合操作的大量计算。

I am looking around redis to provide me an intermediate cache storage with a lot of computation around set operations like intersection and union.

我看过redis网站,并发现redis不是为多核CPU设计的。我的问题是,为什么呢?

I have looked at the redis website, and found that the redis is not designed for a multi-core CPU. My question is, Why is it so ?

此外,如果是的话,我们如何在多核CPU上使用Redis来100%地利用CPU资源。

Also, if yes, how can we make 100% utilization of CPU resources with redis on a multi core CPU's.

推荐答案


我看过redis网站,发现redis不是为多核CPU。我的问题是,为什么会这样?

这是一个设计决策。


Redis是单线程的,具有epoll / kqueue,并且在I / O并发方面可以无限​​扩展。-@ antirez(Redis的创建者)

Redis is single-threaded with epoll/kqueue and scales indefinitely in terms of I/O concurrency. --@antirez (creator of Redis)

选择事件驱动方法的原因是,线程之间的同步在两个线程中都是有代价的软件(代码复杂度)和硬件级别(上下文切换)。此外,Redis的瓶颈通常是 network ,而不是CPU。另一方面,单线程体系结构有其自身的优点(例如,保证原子性)。

A reason for choosing an event-driven approach is that synchronization between threads comes at a cost in both the software (code complexity) and the hardware level (context switching). Add to this that the bottleneck of Redis is usually the network, not the CPU. On the other hand, a single-threaded architecture has its own benefits (for example the guarantee of atomicity).

因此,事件循环对于 高效& 可伸缩 系统,例如Redis。

Therefore event loops seem like a good design for an efficient & scalable system like Redis.


此外,如果可以,我们如何制造通过
在多核CPU上进行redis可以100%地利用CPU资源。

Redis扩展方法 分片 可以在多个内核上使用,主要与 Tempemproxy

The Redis approach to scale over multiple cores is sharding, mostly together with Twemproxy.

但是,如果由于某些原因您仍然想使用多线程方法,请查看 Thredis ,但请确保您了解其作者所做的工作(例如,不能将其用作复制主文件)。

However if for some reason you still want to use a multi-threaded approach, take a look at Thredis but make sure you understand the implications of what its author did (you can not use it as a replication master, for instance).

这篇关于多核CPU上的Redis性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆