void
void

Reputation: 2642

Multi DB join is required for multiple microservices

Please read through this question I have been having and share your thoughts and ways to solve for this.

We are currently building a system consisting of multiple microservices.

For simplicity sake assume the following scenario:

There's

---------| microservice A | microservice B | microservice C |

---------| RDS for A | | RDS for B | | RDS for C|

Now we are struck at a problem where we need

Column Amount from records of Table TA1 from RDS A to sort records of Table TC1 from RDS C

If this were a single DB application we would normally proceed with Joining two tables on the common ID TA1.id = TC1.ta1_id

Since these microservices cannot share a common DB as that goes against pattern of microservices.. what is the best to solve for these use cases?

A new microservice to aggregate data? If so how do we handle memory error if plan on loading every record instead of doing a join i.e two select queries.

Upvotes: 0

Views: 547

Answers (1)

Arnon Rotem-Gal-Oz
Arnon Rotem-Gal-Oz

Reputation: 25909

"Since these microservices cannot share a common DB as that goes against pattern of microservices." That's a pattern ,it has a context and assumptions

  1. Are you sure your services are indeed independent services and not aspects of a single service.? if you find services share a lot of data it might be a good time to rethink your service boundaries
  2. There are still reporting scenarios where it makes sense to take data from multiple services. In these cases I use aggregated reporting pattern where events that occurred are shipped as read-only copies to a central database which organizes data in a reporting friendly way
  3. Another thing that can be done is to cache data from other services in a service - if it was published as an event (preferably immutable and idempotent - so it is always correct for its time) as long as you have some way to understand the data is stale
  4. lastly - sometimes it does make sense to just do "client-side" join -esp. if it is indeed just a one off

Since your question is really generic - it is hard to say which option is right in your case

Upvotes: 3

Related Questions