Should I limit publication over DDP?

I have 2 Meteor apps connected over DDP:

  • App1Server subscribes to a publication of App2Server and stores data in a server-only MiniMongo collection
  • App1Server then publishes some parts of the data to App1WebClient (specified by the web client subscription options)

Now, the questions:

  1. Since there can be thousands of web clients connected to App1Server, and each will request other parts of the data, should App1Server posses all the data published by App2Server?

  2. Since the data in a collection created over DDP connection is stored in MiniMongo (hence RAM), does it mean that all the data, that is published without options from App2Server to App1Server is stored in the RAM and is recomputed even when only one property is changed, or it only stores the requested from web clients parts of the data?

  3. Should App1Server pass the same options to App2Server during subscription?

P.S. Sharing the same DB is not an option.

After reading the docs and experimenting, ended up with following understanding:

  1. Whenever an App1WebClient subscribes to App1Server, a new instance of App1Server publication is created.

  2. Within this each publication instance, there should be subscription to the App2Server (with options).

  3. It is important to stop the App2Server subscription whenever App1Server publication is stopped.

  4. App1Server can have multiple subscriptions to App2Server at the same time.

  5. Every such new subscription can have multiple combinations of options which all will be ‘merged’ on App2Server to make sure the exactly needed amount of data is sent from App2Server to App1Server as requested by all the opened subscriptions (with all their options).

For example:

const App2Server = DDP.connect('https://some.url')
const SomeCollection = new Mongo.Collection('theSameCollectionNameAsOnTheApp2Server', {connection: App2Server})

Meteor.publish({
  'App1Publication' (someOptions) {
    const handler =  App2Server.subscribe('App2Publication', someOptions)
    // important!
    this.onStop(() => handler.stop())
    return SomeCollection.find({}, someOptions)
  }
})

The answer: Yes, one should always limit subscriptions with options, but make sure the subscription to App2Server is always stopped once an instance of App1Server publication is stopped.