Let two services talk via DDP vs. connecting them to the same mongo db

Since networks and stuff were the classes I omitted in favor of other interesting topics (my shame) I am facing a situation, wehre I am not sure what would be the best decision.

My setup is the following:

I have a Meteor Application (called APP) and a standalone Service (also Meteor Application but with only one purpose, called SERVICE).

Now I have one mongodb cluster on AWS (you now, the tutorial manual on AWS…) and both of the applications are connected to the mongodb (called DB), because both need to read and write data, of course.

I have two (three?) possible setups of communication and I can’t see, which is clearly the better solution:

1. Connect both to the DB and let each of them watch the changes of the data in a “shared” collection via pub/sub.

APP <------> DB <------> SERVICE

My fears:

  • Read/write hazards when both read/write the same collection but I am unsure if that happens!?
  • To much data to subscribe and publish, since the apps have to “listen” to a lot of data to “perceive” all changes

2. Have them their own collections in the DB and interchange only via DDP

     / \ Data
    /   \

Here the apps would have separated collections and handle their stuff on their own and then send the relevant data over the wire to each other.

My fears here:

  • Since they have to communicate a lot, I have the fear, that there is a lot of redundancy regarding the data usage, because the most of the data they send to each other would also be stored in the db.

3. Have the data from the SERVICE entirely sent over the wires to my APP and then let my APP send the relevant data to the DB

This seems somehow bloated to me.

As I said I am not the specialist in this topic and just start to learn. Any help (or other concerns) are really appreciated!

For option 1. Take a look at Asteroid https://github.com/mondora/asteroid, a meteor DDP client that connects two or more apps to the same DB, calling server methods, pub/sub and other stuffs. Hope it’s what you’re looking for.