Microservices Architecture: Cross Service data sharing

后端 未结 4 874
醉酒成梦
醉酒成梦 2021-01-30 04:46

Consider the following micro services for an online store project:
Users Service keeps account data about the store\'s users (including first name, last name, email address,

4条回答
  •  闹比i
    闹比i (楼主)
    2021-01-30 04:58

    This seems to be a very common and central question when moving into microservices. I wish there was a good answer for that :-)

    About the suggested pattern already mentioned here, I would use the term Data Denormalization rather than Polyglot Persistence, as it doesn't necessarily needs to be in different persistence technologies. The point is that each service handles its own data. And yes, you have data duplication and you usually need some kind of event bus to share data across services.

    There's another option, which is a sort of a take on the first - making the search itself as a separate service.

    So in your example, you have the User service for managing users. The Purchases services manages purchases. Each handles its own data and only the data it needs (so, for instance, the Purchases service doesn't really need the user name, only the ID). And you have a third service - the Search Service - that consumes data produced by other services, and creates a search "view" from the combined data.

提交回复
热议问题