【发布时间】:2018-07-10 10:36:29
【问题描述】:
我正在做一个使用 jHipster 和微服务架构的项目,我是这项技术的新手,但我真的很关心性能和应用架构。
所以我的用例是有一个网关和另一个微服务, 网关负责管理所有与用户相关的数据,例如最喜欢的餐厅...,而另一个微服务负责餐厅数据管理,包括 crud 和搜索操作。
所以我的问题是,如果我有一个端点来添加一个新的最喜欢的餐厅或为特定用户选择所有最喜欢的餐厅,我将遵循什么方法
PS:我正在使用 mongoDB 来存储数据
1 - 仅将餐厅的 ID 保存在我的用户最喜欢的文档中:
pros :
- they will be no master data management if a restaurant is
updated.
cons :
- there will be a tied coupling between microservices because
requesting favorite restaurant will depend on restaurant microservice
- performance impact requesting list of restaurants in every
favorite restaurant request
2 - 使用嵌入的餐厅文件保存最喜欢的餐厅
pros:
- there will be no tied coupling between microservices
- better performance
cons
- we need master data management for updating data
- what to do if restaurant microservice is down when inserting a new favorite restaurant?
那么选择什么,有更好的解决方案或更好的架构吗? 另一个问题是如何在我的用例中使用 kafka 的好处?
Ps:请记住,我可能会面临大量流量。
【问题讨论】:
-
好问题。我不确定如何限制用户只能看到他们自己生成的条目。示例:博客微服务:* 用户只能看到他们创建/拥有的博客。 * 管理员可以查看每个博客条目。我想做一些类似 Jhipster 视频教程中所示的单体应用程序:youtu.be/XRREt1KB4Y8?t=7m47s
标签: mongodb spring-boot apache-kafka jhipster microservices