微服务依赖uml图

Microservices dependence uml diagram

解释微服务如何相互依赖的最佳图表是什么? 例如下面的情况:

The user service exposes the user_detail endpoint;

The product service exposes the product_item_detail endpoint;

The ordering service exposes the make_order endpoint.

The user selects a product and places an order.

如何使用 uml 解释这一点?

我本来打算使用组件图,但我不明白如何解释每个服务的接口以及它们与其他服务的接口之间的关系。

Microservices are independently deployable components. Therefore, using a component diagram 出现一个很好的直觉:

It specifies a Component as a modular unit with well-defined Interfaces that is replaceable within its environment. The Component concept addresses the area of component-based development and component-based system structuring (...).

在您的组件图中,每个微服务都将显示为单独的 component with the stereotype «service». Since microservices do not just implement an interface but expose it via an endpoint, you should make use of ports

Ports represent interaction points through which an EncapsulatedClassifier communicates with its environment.

提供或需要的接口(棒棒糖和套接字)将连接到端口。端口有所不同:如果没有端口,棒棒糖和套接字也可能意味着 realisation or a «use» dependency 到大型单体中的接口分类器!

最后你的图表可能看起来有点像:

其他想法:

  • 如果您在 «service»«subsystem» 原型之间犹豫不决,您可以考虑创建自己的 UML 配置文件来定义 «microservice» 原型。

  • 如果在一些复杂的图表中您不想显示服务端点的细节,您可以只使用没有 socket/lollipop 的程序集连接器,除了您想要放置焦点的地方。

  • 同样,如果你主要对依赖关系感兴趣,你可能只显示组件及其依赖关系(因为组件是分类器)。

  • 想到微服务,就必然会想到scaling strategies, such as for example having several instances of the same service running on several containers/servers, or heving several instances of the same microservice partition the data. This kind of though is about deployment scenarios of the components. You may then consider deployment diagrams。但这远远超出了你的问题。