1

我听说了很多关于 Redis 服务器提供的超快速度的信息,因此想到将其插入我现有的 Rails 应用程序之一,该应用程序在 PostgreSQL 上作为数据库服务器运行。

我的问题是,如果我的系统上有大约 100000 个用户并且想要实现一个追随者/追随者模式,我可以使用 Redis 的 SET 数据类型左右。但是根据用户拥有 100000 个不同的键是一个好习惯。这是在我当前场景中定义键的正确方法吗?如果是这样,单个redis实例上的数字键限制是多少。

欢迎提出更好的按键设计建议。

4

1 回答 1

3

Redis has no problems with handling millions of keys. The theoretical limit is 2^32 keys (see FAQ), so in practice the amount of available memory is the only limiting factor.

Since Redis natively supports only two levels of hierarchy: keys and lists/hashes/sets, having a key per user is pretty much the only option in this case.

Redis uses very compact representation for small sets, so if most of your users have only a few followers, memory usage should be reasonably low. Adjusting *-max-ziplist-* family of configuration options may give results optimal for your particular data set.

By the way, you may be interested in how people at Twitter handle tremendous follower-generated load, using Redis for the part of their stack: real-time delivery architecture talk is very interesting.

于 2013-08-25T14:00:22.590 回答