Microservices. Data management between services
What is a microservice?
With a monolithic architecture, this is a way to build servers in a monolithic server.
All the code needed to implement our application inside of one single code base and we deploy that code base as one discrete unit.
A monolith contains
to implement all features of our app
Microservice architecture.
With this microservice architecture, we’ve now split off all these different features and wrap them up inside of their own little personalized services.
A single microservice contains
to implement one feature of our app
Data management between services
This is the big problem of microservices. When we say data management, we are talking about the way in which we store data inside of a service and how we comunicate that data between different services.
Whenever we are making use of microservices, we are going to create a separate database for each service.
Why Database-Per-Service
If we want to to actually show information about those products, we probably have to do a query over to the products collection as well. We’re accessing these three different sources of information to implement this one single feature and inside of a monolithic server.
How could we somehow get information required to implement Service D feature without reaching into these databases?
We don’t allow these services to interact with each other’s databases. That is why data management between services can be really, really challenging.
Microservices Sync Communication
In Sync Communication there are some upsides but there are a lot of gigantic operational downsides as well.
Microservices Async Communication
First way
Second way (crazy way of storing data)
Create a product
Create a user
Order a product
Soon I will create a post where we will see how to create microservices with NodeJS and React. We will go this second way to create the microservices and store the information. This is a topic we haven’t seen in Google Cloud Microservices post.
Leave a Reply
Want to join the discussion?Feel free to contribute!