דיון מרובה על שרת Redis בודד

סיכום מבוסס בינה מלאכותית

In a discussion titled ‘Multiple discourse on a single redis host’ under the Hosting category, pfaffman shares their experience using multiple Discourse containers behind a reverse proxy on one server, initially relying on DISCOURSE_REDIS_DB to separate instances on a single Redis server. After being advised against this practice due to potential issues with Redis Pub/Sub (which is shared across all Redis databases), they switched to running separate Redis instances per site for clarity and safety. david confirms this is necessary because Discourse’s message-bus relies on Redis Pub/Sub, which isn’t isolated between databases — unlike multisite installations, which automatically prefix keys and channels per site. pfaffman appreciates the clarification. Farley criticizes this as an architectural oversight and suggests enabling Redis key prefixing even in single-site setups, arguing it would simplify managing multiple Discourse instances on one Redis host — a change they believe would reduce complexity and overhead for users needing multiple installations.

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.

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.

Perfectly understandable. Thanks very much for your lucid explanation!

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.