0

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.

1
  • If the query is a read-only query you can use the CQRS pattern. Commented Jul 19, 2022 at 13:15

1 Answer 1

3

"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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.