Performance: connecting 2 databases with Meteor App

I am using 2 databases to make my RESTful API work.
Say DB1 and DB2. Both of which are on the same database server i.e. myhost:27017

I can fetch from DB1 simply using
for example:
User = new Meteor.Collection(‘user’);

For the second one I am using :
var DB2 = new MongoInternals.RemoteCollectionDriver(“mongodb://Myhost:27017/DB2”);
MyCollection1 = new Meteor.Collection(‘Collection1’,{_driver:DB2});

Will this cause performance issues(delay) while fetching from DB2.

Is there a better way to do this?

Any help will be appreciated. Thanks.

I haven’t tried this before, but the internals of the mongo connection method will be the same for both DB1 and DB2 in your example. DB1 is just the default and doesn’t require naming.
There shouldn’t be any extra delay over having both connections in the one DB

1 Like

both should enable oplog

It will not cause performance issues. It’s just the fact that Meteor will keep 2 socket connections open instead of 1.

1 Like

I don’t think you get oplog support unless you configure it like this:

var DB2 = new MongoInternals.RemoteCollectionDriver('mongodb://localhost:27017/DB2?replicaSet=rs0', {oplogUrl:'mongodb://localhost:27017/local?authSource=DB2'})

At least that’s how I have it. Haven’t touched it in long time and don’t quite remember.

2 Likes

Thanks for your response. Answers my query.

Thanks this solved the next step for me :smile: