I am working micro service architecture and figuring out what is the best way to get complex data from a micro service. So for example : Let's say micro service A is owning data based on any CRUD operations, there are X,Y,Z services which requires some sort of aggregated info and conditional info from micro service A, what is the best way to go implement it ?

  1. One could be writing methods in A which generate realtime data and send back to other micro services
  2. Second could sending events from micro service A to other micro services to update their view of data, and reflect that back to other micro services

FYI I am using mongoDB as data base and node.js as application.

  • both have advantages and disadvantages. you'll have to add some info about the users of the service – Ewan Oct 13 '17 at 9:02
  • Okay, so for example let's say I am creating social network backend system, in which I am creating a review microservice. Now there are other services for example customer profile / avg review on platform in country etc and customer profile will only get those reviews which are from last 20 days. This is an example of conditional plus aggregated query. – mohit3081989 Oct 13 '17 at 9:07
  • Id go with 1 in that case, as you have many users and the data is not time sensitive – Ewan Oct 13 '17 at 9:12
  • Won't the expose problem of one micro service becoming bottleneck for such data ? If review service goes down, other will be getting impacted by it, also single service will have to expose hell lot of methods to scale out based on various use cases. – mohit3081989 Oct 13 '17 at 10:44
  • Why should review service be worried about, how other services are consuming its data ? Like why it should write logic for profile getting reviews info in a particular order with constraint text limit etc. ? – mohit3081989 Oct 13 '17 at 10:46

So basically there are following ways to sharing data that a particular domain (from domain driven design world) owns. Which is :

  1. Functional methods
  2. CQRS : Commands query responsibility segregation where query model sits separately to honour any query for particular data present in a domain.
  3. Event streaming : Any particular service needs to publish some kind of events which will allow dependent services to consume then to update their own view or interpretation.
  4. Event sourcing : Have everything on event bus which is some sort of persistent event logs and all micro services derive data out of it through filtration and projection.

In any micro service world, best approaches are either combination of CQRS and event streaming or event sourcing.

I will personally go with CQRS with event streaming for now, seems stable and feasible solution for now. I am leaving respective details upto you guys to figure out. Suggestions are respected, and please correct if people think otherwise.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.