Search code examples
databasewebarchitecturemicroservices

How do I manage multiple databases on microservices?


Create a single database for different microservices is anti-pattern, then the correct way is to create a database for each microservice. But when the database is a relational type, I will duplicate tables that have relationships between the microservices, but how can I have two different databases sync with each other? Thinking an application in Node with database postgres where I have products, clients and sales, three microservices, sales need clients and products then how I maintain my databases sync?

Regards!


Solution

  • This is one of the main problems in the micro service architecture that is being addressed using the pattern:

    Also associated with this pattern are:

    But this solves only part of the problem.

    Building a micro service architecture is a very complex and extensive task, and it is associated with many problems and design patterns that allow you to minimize these problems. I recommend reading a book "Microservices patterns" that looks at various patterns of micro-service architecture design.