Nirmal
Nirmal

Reputation: 161

Best way to use a table among multiple microservices

I have three Microservices and all have their own databases but I have a situation where I need to use a table which is in the database of another Microservice.

What would be he best way to overcome this, I need to join that table with existing DB table. So basically how to join two table from two DBs. I have some ways but not sure which is the best

  1. Use duplicate tables as this table rarely gets updated
  2. Use another DB which is shared among all Microservices
  3. Call API and get data and then map records on coding side

Upvotes: 0

Views: 831

Answers (1)

justincely
justincely

Reputation: 1080

Of the three options there, #3 is the best option to keep everything separate and isolated. But there are some options to this depending on the needs and how the service uses the information. If it's really infrequently updated like you indicate, then one option would be to simply have the service call the other API to get the data it needs on a regular interval and then to store that in it's own database as a new table. Then, since the table is now in the local service, you can perform joins as you wanted.

Upvotes: 1

Related Questions