Ricky
Ricky

Reputation: 2907

Databases in a microservices pattern/architecture

I'm trying to understand the layout of the microservices pattern. Given that each microservice would run on its on VM (for sake of example) how does the database fit into this architecture?

Would each service, in turn, connect to the consolidated database to read/write data?

Thanks for any insight

Upvotes: 4

Views: 646

Answers (2)

Richard Li
Richard Li

Reputation: 528

There's no one size fits all solution.

The general principle is that each microservice should make the right decision for itself in terms of what the right persistence architecture should be. It might be connected to a central SQL database, or it could be using a filesystem, or it could be using NoSQL data store, or memcached, or whatever. (This is why people talk about eventual consistency a lot with microservices.)

You want to do it this way to really capture the benefits of microservices.

  1. You want each microservice to be independently shippable, so that you're not blocked on anything. Stronger coupling to centralized infrastructure reduces the independence of the microservice.
  2. Persistence requirements are highly variable. If you're running a search microservice, you don't need the ACID semantics of a typical SQL database. If you're doing payments, you need ACID. If you're storing and processing images, you might just use the filesystem. Etc.

Upvotes: 2

ekostadinov
ekostadinov

Reputation: 6950

In my experience when dealing with mSOA it always comes to Data Warehouse solution in the end. And this is the natural choice if you have a dedicated DB (cluster) per micro-service. After all the business should be able to use that info from your domain. Even Data Vault Modeling will be a good fit here.

Upvotes: 0

Related Questions