This question already has an answer here:
I have been looking at Microservices for a while now. The concept is not new but it's communicated in a lightweight manner. So, I am very excited about this.
However, there is a question that I am not sure what the answer is: is each microservice supposed to have its own isolated data storage model completely? Consider the below:
Note: This is probably not a good example as the seperation here is done based on read/writes whereas the good approach would be to separate the business concerns.
- products-write-service: responsible for dealing with creation and edits of the products. Knows MongoDB and writes data to there.
- products-lookup-service: responsible for dealing with retrieving products by their identifiers, providing basic listing of products based on categories, etc. Knows MongoDB and reads data from there.
- products-search-service: responsible for dealing with search requests on products. Knows Elasticsearch and reads data from there.
Here, we have two separate data storage techs between three services. However:
products-lookup-serviceworks on the same data storage model. There is a tried relationship between two services.
- at the end of the day, there should be a process to do ETL from MongoDB to Elasticsearch for
products-search-serviceto function. In some sense, three microservices have their own data storage model but there is a middle process which knows about these two models.
What do you say about this model? Is the separation completely wrong here?