0

我正在使用 node 和 php ,对于 node ,我听说过 redis 用于缓存系统和 php memcached

我已经测试了设置和获取 10000 个项目的简单测试:

memcached 比 redis 快 10 倍(是的,10 倍),很容易说 memcached 在速度方面更好。

但我听说 memcached 不像 redis 那样缩放,是真的吗?我可以看到,当我想用​​添加服务器功能连接 memcache 时,我可以使用多个服务器,那么,为什么人们说这在规模方面不好呢?

为什么我应该在 Node 中使用 redis 而不是 memcached?

4

2 回答 2

4

如果您再深入一点,您会发现,memcache 是多线程的,但 redis 主要是单线程的(请参阅Redis 的单线程性质)。

因此,如果您要在多核处理器上进行基准测试,memcache 将能够利用内核扩展其性能,而 redis 则不能。

为了弥补这种单线程特性,正在开发 redis 集群(就像节点具有集群模块一样)。Memcache 已经是分布式的并且支持集群。Redis 预计将在今年年底推出集群(稳定版)。请记住,它仍然是新的,而且 memcache 已经存在了十年。

在所有基准测试中,我找到正确解释基准测试各个方面的一个。查看最后一个没有并行性的基准。他们的表现几乎不相上下。

编辑

关于它们之间的选择,这个问题与 Redis 相比,memcached 是恐龙吗?有很多很好的答案,尤其是这个。回答这个问题的同一个人做了这些基准测试:

  1. http://oldblog.antirez.com/post/redis-memcached-benchmark.html
  2. http://oldblog.antirez.com/post/update-on-memcached-redis-benchmark.html

此外,您需要了解的有关性能和基准测试的大部分主题都在这里给出,包括上面提到的所有基准。

于 2013-07-18T06:35:15.790 回答
2
  1. My guess is you didn't configure Redis optimally, or there was something else wrong in your test. There have been a lot of benchmarks done against Redis and Memcached and the results are always close, frequently with Redis as the winner.
  2. There is a detailed response to why to use one vs the other at this SO question.
于 2013-07-18T06:10:19.223 回答