Question

We're rebuilding a system in a microservice archiecture. I know the standard practice for SOA is to have each individual service responsible for its own database.

However, does it make sense to have one 'database' service responsible for handling a monolithic database (i.e. holding users, orders, inventory, etc in one db)? Is this something that's considered reasonable?

Or is the expectation that users, orders, inventory will all have their own separate databases and according services? If that's the case, how do I handle it when I want to do a simple relational query like ordering a list of inventory by how many orders we've had for each item?

Edit: not duplicate. to clarify (from comments): I understand that it's bad to share databases among multiple microservices. my question is whether having a big central database managed by a single microservice is a bad idea, or if it's critical that the internal system's data be decoupled itself

Was it helpful?

Solution

However, does it make sense to have one 'database' service responsible for handling a monolithic database (i.e. holding users, orders, inventory, etc in one db)? Is this something that's considered reasonable?

I think this is a mistake to make a service (or whatever) in SOA or any other architecture responsible for a database or a part of database or a table or whatever database part you can imagine.

Service is about fulfilling a user (or may be other service's) request. Database interaction is only a secondary to that. Microservice servers a group of requests, not a group of tables.

It is my understanding, that services are usually designed to use a dedicated database just to ensure maximum decoupling. This way service data is physically separated from the data of another service. Also this decision allows you to easily move service to a new platform (just move service app server + database into another machine).

You can use single database if you will find other means of keeping your services decoupled and if you will not be too troubled with moving a specific part of your database to, say, another machine (figuring out which part of database belongs to which service is sometimes not easy).

Licensed under: CC-BY-SA with attribution
scroll top