Share MongoDB With separate Rocket Chat Servers

Description

Hi! For sake of learning, I want to deploy two separate Rocket Chat instances, serving two distinct audiences (two tenants: I want them isolated). Considering Rocket Chat does not support multi tenancy, I need to deploy two separate Rocket Chat Servers, each serving a different audience. My question is: It’s necessary to have separate MongoDB instances or can I share the MongoDB instances and use separate databases for each Rocket Chat server?

Answering my own question (Home someone can validate / correct my conclusion).

It’s not possible to share mongoDB instances with two separate tenants because Rocket Chat uses Meteor Oplog tailing and mongodb oplog is global and not per database.

@ralg Welcome :wave:

You are right with the OPLOG being global across all databases inside the database management system Mongo, but this is not a reason not to utilize two databases inside the same Mongo DBMS: The OPLOG is a mechanism of the DBMS to balance to balance load and be resilient, but it does not break DB isolation.

You just have to provide two different MONGO_URL environmen variables to the two Rocket.Chat node services on start.

Cheers, Oliver

Hi @ojaegle :wave: ! Thank you for your answer.

If meteor reads oplog to deliver realtime updates across multiple hosts (to avoid the overhead of poll-and-diff) and oplog is global, how does meteor filter oplog entries per Rocket Chat cluster? :thinking:

Thank you!

Sorry to dig up an old conversation but i have the same question.

I’m running a multi tenant mongo environment, but have multiple (tens) of front end rocketchat nodes. I see a lot of load on the oplog if i reboot the server that hosts all the node processes.

Is it possible to have multiple oplogs so there’s one per db? Generally i think what happens is that the node processes read the oplog, but it contains a lot of stuff they dont need to worry about…so it just results in lots of excess load (i.e. one event gets read every time because its in the oplog, but its only useful to one of the servers).