I have an admin app and a client app that share the same Mongo DB and
Collection definitions (via symlink files). The client app users (1000+ simultaneous) all need an individual
status at the same time that has to be heavily computed based on several
Collections in the database.
To do this, my admin app, at the right time, computes a set of statuses for all 1000 client app users and stores it in an ephemeral server-var dictionary. The set of statuses is totally ephemeral, refreshes often, and does not need to be persisted to DB and I’m actually trying to avoid that to reduce my DB load from all the client app users.
So my client app users all retrieve their status using a Meteor Method. However, the client app cannot just call
Meteor.call('getUserStatus', userId, ...) because the ephemeral dictionary that the Meteor Method needs to access is on a different server. No problem, just do this:
var adminAppConnection = DDP.connect('https://myadminapp.abc'); adminAppConnection.call('getUserStatus', userId, ...)
And this works as expected. The problem I think I’m going to have is in production where my admin app has multiple containers on Galaxy, if I just connect via the URL of my admin app, isn’t it likely that it could connect to a container that is not the one computing the ephemeral dictionary that my client app needs? I’m assuming ephemeral values like this are not shared between containers. They only exist on the container where the admin app user caused them to be generated.
Is there any solution for this? The only things I’ve thought of so far are:
I could publish the ephemeral dictionary of statuses using
this.added(...)and subscribe to it in the client app using a client-only collection (which is kind of cool), but even if I used a
limit: 1to just get single status (based on the client app userId) every client would call that publication that evaluates and creates the dictionary. The idea behind the above pattern is to call a Meteor Method and get a simple text status back that’s already been computed on the (admin) server so the client doesn’t have to hit mongo, download a publication, or do any work.
Persist the status dictionary to an actual database Collection and just query it via a Meteor Method (to avoid pushing all statuses to the client), but that means every client (1000+) hits the database at the same time to get their status which I’m trying to avoid (though this may be the most reasonable non-third-party solution).
Get the URL to to the correct admin app container (there must be a way as Galaxy can show you the URL of a given container and connect you to your app using it - e.g.
https://myadminapp.abc/?_g_container_=<id>&_g_debug_=true)and make sure the client app is connecting using it. This could be problematic though as I assume that URL changes all the time if your containers change out for whatever reason. So there would have to be some kind of updating if that URL changes and that may not work in my use-case. The admin app user can sign out and the client app still needs to get that status from the dictionary, so there may be no way to know what the correct, current URL is of the admin app. I do have parent document that connects the client users and the admin app to one “grouping” and I could save the admin app URL in that document, but the URL could still get updated after the admin user signs out. This just seems hacky and it also assumes my admin app is going to handle 1000+ simultaneous
Use something like
redis-oplog's Vent tool, where you pub-sub using Redis. Perhaps I can publish the dictionary or even each user’s status and they access it via Vent. This may also be a good solution.