I’ll first give a bit of context on the issue i’m trying to solve and then throw some questions on the end, thank you in advance for reading and for any adivice!
As most of you know it comes a time on one’s application where the work has to be split between different processes and responsibilities.
Currently i’m basically splitting my application into “dashboard” and “workers”, the dashboard is - you guessed right - my meteor application and only have publications, subscriptions, accounts, roles and show important information for it’s users.
On top of that i have three workers at the moment, each of them connects to their own MongoDB instance this way reads and writes from each worker doesn’t really interfere with other worker’s performance, also means it’s easier to scale each part of my application.
Since speed of development is important to me i end up making all the workers “vanilla node.js” apps so on every change they restart very fast ( and run their tests ), it all happens very fast compared to re-booting up a meteor app every time my server code changes.
At first this sounded like the best idea hands down, but realistic speaking after i’m half-way there i realised that the beautiful Collection Hooks / Collection2 features i have on my main app doesn’t really happen on my workers and even if it did i would have to re-implement some of those features on my workers and/or share files between workers and the main meteor app at this point things can get a confusing and not very practical, for instance having schemas defined on my meteor app and also on my node.js apps.
That’s when i decided to search for “meteor workers” to see how people generally solve this issue and found out this package which seems to be very interesting: https://github.com/Differential/meteor-workers i’m just not really sure what the author means by “headless worker meteor processes”, anyone has an idea of what that actually means - can you boot meteor in “server-only mode” and ignore all code related to the client side of things?
During the research i also seen @slava has spoken on the issue here: https://crater.io/posts/cE6hFfXXiGfT2FmBw and another interesting project shown up his article comments: https://github.com/vsivsi/meteor-job-collection
- What is the recommended way of creating workers for meteor apps ?
- Is it a good idea to have meteor workers instead of vanilla node.js ?
- Can you imagine a nice way of sharing schemas / hooks between main app and workers?
My answers and my conclusions so far:
It seems that having meteor-enabled workers would be ideal so the hooks and schemas would be easily shared with the application itself but in the other hand when developing the restart time of the application could slow things down, maybe if there was a way of booting meteor without all the “http / sockets / client” part of it as in: only the server bits ( is that what a headless meteor mean? ) would speed up the development / testing time of the workers? I don’t know if that is even possible.
Developing and testing vanilla node.js proccess is very easy and fast but unfortunately it means some of the logic is being duplicated between projects and repositories, unless i to add all files ( app + workers ) on the same repository - which is more and more looking like a good idea to me - and somehow share the schema files, still it doesn’t seem like i would get the “Collection Hooks” functionality shared between them unless i make all my worker meteor-apps - which is also starting to sound like a great idea to me.
I’m still looking around and reading the implementations from the projects i found but i thought would be a good idea to come here and ask more experienced developers.
Thank you for reading, any advice / experienced shared will be greatly appreciated!