如何为微服务创建边界? [英] How do I create boundaries for my microservices?

查看:127
本文介绍了如何为微服务创建边界?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个基于Web的整体CRUD应用程序(称为A),它可以完成某些任务.现在,我们有了一个新的要求,该要求在功能上或多或少地独立于A.听众不同,使用时间,功能等也各不相同.因此,我们决定将其构建到新的服务B中.

We have a monolithic web based CRUD application (call it A) which does a certain task. Now, we have a new requirement which is more or less independent of A functionally. The audience is different, the times of use, the functionality etc. are all different. Because of this, we decided to build this into a new service B.

B需要来自A的身份验证信息时,问题就开始了.预期会再次发生这种情况,我们从A中取出了auth并将其作为单独的提供程序C. AB都可以针对现在包含用户信息的C进行身份验证.

The problem started when B required authentication information from A. Anticipating that this might happen again, we pulled out the auth from A and put it as separate provider C. Both A and B can authenticate against C which now contains the user information.

接下来出现的一个问题是用于保存用户配置文件的用户配置文件A是什么,但是现在,我们将其大部分移到了C.但是,我们需要保留一些额外的字段,以保持B的需要.问题是我是否应该

The next question that came up was what about user profiles A used to hold the user profiles but now, we moved most of it to C. However, there are a few extra fields that we need to keep which B needs. The question is whether I should

  1. 保留C中的所有字段,因为它是身份验证服务和保留所有用户信息的地方.
  2. 将其保留在B中,因为它是唯一需要它的地方.
  1. Keep all the fields in C since it is the authentication service and the place to keep all user information.
  2. Keep it in B since it's the only place it will be needed.

更笼统地说,我的问题是如何决定如何将整体分割成几个独立的部分,如何拆分数据以及我如何处理在所有服务中共享"的userid之类的东西?/p>

More generally, my question is how to decide how to carve up the monolith into separate pieces, how to split the data and what do I do about things like userids which are "shared" across all the services?

推荐答案

我同意Gilbert的评论:与用户相关的数据字段应保留在用户身份验证服务中.

I agree with Gilbert's comment: Data fields that are related to the user should be kept in the user authentication service.

通常,可能没有一种设置边界的正确"方法,但是确实存在一些通用概念,例如

In general, there is probably not the one "correct" way to set the boundaries, but there do exist some general concepts such as the idea of bounded contexts. Also, an important objective that you should keep in mind when dealing with a microservices architecture is that services should be able to be developed and deployed independently of each other.

有关该主题的更多资源和最佳实践,我认为是有用的:

Some more resources and best practices on the topic that I have found useful:

  • How to break a Monolith into Microservices
  • Using domain analysis to model microservices

这篇关于如何为微服务创建边界?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆