Multiple discourse on a single redis host

One setup that I use I have multiple discourse containers running behind a reverse proxy on a single server. For a time, I was using

DISCOURSE_REDIS_DB: x

to allow multiple Discourse servers to use a single redis server. Largely because I am lazy and don’t like keeping careful track of which server is using which number, I wanted to increase the number of redis DBs in redis to more than 16. When I asked about such, the answer I got suggested that it is a very bad idea to use redis_db to have multiple sites on a single redis. And since then I have reconfigured things to spin up a separate redis for each site (which makes them easier to keep up with since I can use a name for them).

But this seems a little silly. And now that I’m looking, I see this:

So, I was wondering if it’s OK to use redis_db or whether each Discourse needs its own redis.

1 Like

Each Discourse needs its own totally separate redis server because message-bus uses Redis Pub/Sub, which is shared between all databases on a Redis server.

If you run Discourse in a multisite configuration, then we automatically add a site-specific prefix to all keys and pub-sub channels. That same prefixing is not available for standard ‘single site’ installations.

4 Likes

Perfectly understandable. Thanks very much for your lucid explanation!

2 Likes

This seems to be a gross architectural oversight. Could you please make redis key prefixing possible in a single-site installation so we can have multiple installations of Discourse on one redis host? Unless I’m misunderstanding something, this is a very simple solution that would greatly reduce the complexity and overhead for folks that need to run more than one discourse.