Eli Rose
Eli Rose

Reputation: 6988

Best practices for multiple Redis instances on Heroku?

I'm planning on adding a second Redis instance to my Rails application. From reading the docs, https://devcenter.heroku.com/articles/heroku-redis#establish-the-primary-instance, the best practice for doing this on Heroku seems to be to designate one of the instances as the "primary" instance, point to it with the REDIS_URL config var, and have another config var with some other name pointing to the second instance.

This doesn't quite suit me, since I have more semantic names I'd like to use.

How important is it to designate one of my instances as "primary"? What do I get by doing so? The docs contain sentences like 'Heroku recommends using the REDIS_URL config var to store the location of the primary instance' but don't go into further detail.

Upvotes: 3

Views: 1170

Answers (1)

Eli Rose
Eli Rose

Reputation: 6988

There is nothing magic about REDIS_URL. Quoth support:

While Heroku recommends to establish a single data store service as a primary and some tools are built around this convention, it is surely possible to have more than one data services with other config var names.

To specify a semantic name for the config var, please add an --as option to the addon:create command like so:

heroku addons:create heroku-redis --as PERSISTENT_REDIS -a my-heroku-app

Moreover, an existing add-on can be attached through a different config var like below. Please refer to the output from the heroku addons command to see what is the add-on name (redis-abc-1234 in the example below) to be used.

heroku addons:attach redis-abc-1234 --as VOLATILE_REDIS -a my-heroku-app

Upvotes: 8

Related Questions