多个Redis实例 [英] Multiple Redis Instances

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

问题描述

大多数人似乎建议在不同的端口(6379 和 6380)上运行单独的 Redis 实例.为什么这比创建第二个数据库更常见?我还没有完全阅读文档,但大多数示例在连接时并没有真正提到选择 Redis 数据库".来自 Ruby 客户端的示例,nrk/predis 的自述文件:

Most folks seem to recommend running separate Redis instances on different ports (6379 and 6380). Why is this more commonly recommended over creating a second database? I'm not completely through the documentation yet, but most examples don't really mention 'selection of a Redis database' when connecting. An example from the Ruby client, nrk/predis's README:

$redis = new Predis\Client(array(
    'scheme' => 'tcp',
    'host'   => '10.0.0.1',
    'port'   => 6379,
));

我们目前在办公室使用 Campfire 运行 Hubot,我正在为 GTalk 开发第二个,因为每个 Hubot 实例只能使用一个适配器.因此,我正在考虑创建第二个数据库或 Redis 实例,以便隔离两个 hubots 之间的数据.但在深入了解之前,我想了解为什么要使用单独的实例而不是仅仅创建第二个数据库.

We currently run Hubot in our office with Campfire, and I'm working on a second one for GTalk since you can only have a single adapter in use for each Hubot instance. So I'm considering creating a second database or instance of Redis so that data between the two hubots is isolated. But before I got much further, I wanted to understand why you would use separate instances instead of just creating a second database.

推荐答案

两个主要原因:

  1. 使用多个数据库通常被认为是不好的,总有一天会被弃用,它们会产生一些性能损失,尽管非常轻微.

  1. using multiple databases is considered generally bad and to be deprecated some day, and they have some performance penalties, though pretty minor.

主要原因是 redis 是单线程的,如果您需要两个不同的数据源,另一个 redis 实例将提高性能,因为它将使用您可能拥有的另一个 CPU,而一个实例将始终只使用一个.

the main reason is that redis is single threaded, if you need two different data sources, another redis instance will improve performance since it will utilize another CPU you probably have, whereas one instance will always utilize just one.

此外,不同的 redis 实例可以具有不同的持久性设置.例如,一个实例只能使用内存,其他实例可以使用文件作为存储Redis 持久化

Also different redis instances can have distinct persistence settings. For example one instance can use only memory and other can use files as storage Redis Persistence

然后还有其他优势,例如具有单独的身份验证密码、LRU 策略等 - 这些只能在实例级别完成.

Then there are other advantages as having separate auth passwords, LRU strategies, etc - which can only be done at the instance level.

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

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