gpt4 book ai didi

Redis 在多核 CPU 上的性能

转载 作者:IT王子 更新时间:2023-10-29 05:54:39 25 4
gpt4 key购买 nike

我正在寻找 redis 为我提供一个中间缓存存储,其中包含大量围绕集合操作(​​如交集和并集)的计算。

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

此外,如果是,我们如何在多核 CPU 上使用 Redis 实现 100% 的 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?

这是一个设计决定。

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

选择事件驱动方法的一个原因是,线程之间的同步会在软件(代码复杂性)和硬件级别(上下文切换)上付出代价。此外,Redis 的瓶颈通常是网络或*内存,而不是 CPU。另一方面,单线程架构有其自身的优势(例如保证原子性)。

因此,事件循环似乎是一个很好的设计 efficient & scalable像 Redis 这样的系统。

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

在多核上扩展的 Redis 方法是 sharding ,主要与 Twemproxy 一起.

但是,如果出于某种原因您仍想使用多线程方法,请查看 Thredis但请确保您了解其作者所做的事情的含义(例如,您不能将其用作复制主机)。

关于Redis 在多核 CPU 上的性能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21304947/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com