Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple Redis Instances

Tags:

redis

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.

like image 920
brock Avatar asked May 17 '12 22:05

brock


People also ask

Can Redis have multiple databases?

Redis comes with support for multiple databases, which is very similar to the concept in SQL databases. In SQL databases, such as MySQL, PostgreSQL, and Oracle, you can define a name for your databases. However, Redis databases are represented by numbers.

Is Redis single instance?

Much like schemas of traditional RDBMSs, Redis' databases are managed by a single instance of the Redis server but are kept logically separated. The main benefit of having a single Redis instance manage multiple databases is a reduction in administrative overhead.


1 Answers

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.

like image 95
Not_a_Golfer Avatar answered Sep 20 '22 07:09

Not_a_Golfer