Best practice to share domain model between two microservices

眉间皱痕 提交于 2020-07-09 12:20:47

问题


Are there any best practices or guidelines on how to share the domain model between two micro-services?

I have a micro-service (1) which provides end points to interact with a resource (e.g, Order) all CRUD and the other micro-service (2) which performs a specific non CRUD task on the resource (Order). The micro-service (2) almost needs all the order attributes to perform its operation. In this case, does it make sense to create a common shared lib of the domain model and share between the two services? I could technically combine 1 and 2 together but the micro-service (2) needs to support scalability as it is quite memory and CPU intensive.


回答1:


As far as I can see it seems that these two services need to share the same data and you are thinking to share also the library that is used to read/modify this data.

They seem to belong to the same "bounded context" and so it would be ideal to consider them as a unique service.

If you really can't separate their data and their logic, it would be better to keep them together.

I do not think that components in the same microservices have to follow the same deployment pattern: they will be the same microservice, managed by the same team, deployed always together, sharing the same source repository, but they will be deployed with a different strategy because only the second component needs high scalability.

So same bounded context, same service, but different components.

I do not have a lot of experience and so take this as my personal thought.



来源:https://stackoverflow.com/questions/47860278/best-practice-to-share-domain-model-between-two-microservices

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!