Thanks for sharing. Can someone speak to the benefits or downsides of the /api structure specifically separating /services and how it might work in practice? I think I understand but hadn’t seen this shared before and am wondering why it wouldn’t be the default recommended structure in the Meteor tutorials.
So your micro-services would then have to run their own authentication etc.? I.e. - It would have to be available just to your Meteor server and nobody else. Is that right? How do you go about doing that?
Can someone speak to the benefits or downsides of the /api structure specifically separating /services and how it might work in practice?
I tried to explain the benefits in my blog post, but I don’t think I explained it very well.
By moving the business logic of the application to the /services folder you are able to easily convert your monolithic application to a microservices application by service as your application grows.
So your micro-services would then have to run their own authentication etc.? I.e. - It would have to be available just to your Meteor server and nobody else. Is that right? How do you go about doing that?
That is correct. My recommendation would be to have your microservices in a private VPC that is only accessible from you Meteor cloud-instances, and always use some type of authentication for your microservices.
Here is an example of VPC architecture utilizing NAT gateways to have your Meteor instances publicly accessible, and your microservice instances privately accessible.
I’m not super familiar with microservices so forgive my potentially dumb questions. I’m wondering why you wouldn’t want to have {CollectionService}.js in the same folder as /{Collection Name}. Is it to ease portability when creating a new microservice or is there some other motivation?
If I’m understanding correctly, your Methods would basically just be calling another function in CollectionService.js so do they look something like this? Or do they have more responsibilities?
import { exampleFunction } from '../services/CollectionService.js';
Meteor.methods({
'methodName': exampleFunction
});
So in this scenario each microservice is still a full Meteor application, is that right? And you’re just routing specific methods to specific instances? Meteor itself has quite a bit of overhead (which is justified for all of the nice things that it offers IMO) but if I were making the effort to split a method out into its own microservice for performance reasons I’d probably just move it into a basic node lambda to make it much cheaper and faster than a second full Meteor app. It’d be interesting to see a cost + performance comparison of splitting some intensive task into its own Meteor microservice vs just a lambda microservice.