Multiple Redis Instances

2020-06-09 04:09发布

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,
));

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.

标签: redis
1条回答
别忘想泡老子
2楼-- · 2020-06-09 04:26

Two main reasons:

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

  2. 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.

  3. 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

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

查看更多
登录 后发表回答