微服务通信设计
Microservices Communication Design
我想知道如何为每个服务创建通信。我在系统外部使用 API 网关与内部服务进行通信。一个服务是否有必要通过 API 网关调用另一个服务或直接进入服务本身?
谢谢
Api 内部服务到服务的通信不需要网关
但是,您需要服务注册表或某种动态负载平衡机制才能访问服务
您可以通过多种方式设计沟通策略。显然你可以使用你的 API 网关来做到这一点(我假设你正在使用这个 pattern) but this isn't a good idea because to begin it is not a good use of the pattern and for other hand many people think that the use of apirests should never be used to inter-communication of mservices. One a best approach to make this instead is base the communications on asynchronous message-passing, to do this you can use Publish–subscribe pattern, but always you can take a look to Event Pattern 也很常用。
这是一些可能对您有帮助的文章的简单列表,请看一看:
- Building Microservices: Inter-Process Communication in a Microservices Architecture
- Why RESTful communication between microservices can be perfectly fine
- Pattern: Messaging
- Technical Approach of Inter-Service Communication
如果您以前没有这方面的经验,那么信息量很大,但通过一些研究,您很快就会发现在您的项目中使用的好策略。
我想知道如何为每个服务创建通信。我在系统外部使用 API 网关与内部服务进行通信。一个服务是否有必要通过 API 网关调用另一个服务或直接进入服务本身?
谢谢
Api 内部服务到服务的通信不需要网关 但是,您需要服务注册表或某种动态负载平衡机制才能访问服务
您可以通过多种方式设计沟通策略。显然你可以使用你的 API 网关来做到这一点(我假设你正在使用这个 pattern) but this isn't a good idea because to begin it is not a good use of the pattern and for other hand many people think that the use of apirests should never be used to inter-communication of mservices. One a best approach to make this instead is base the communications on asynchronous message-passing, to do this you can use Publish–subscribe pattern, but always you can take a look to Event Pattern 也很常用。
这是一些可能对您有帮助的文章的简单列表,请看一看:
- Building Microservices: Inter-Process Communication in a Microservices Architecture
- Why RESTful communication between microservices can be perfectly fine
- Pattern: Messaging
- Technical Approach of Inter-Service Communication
如果您以前没有这方面的经验,那么信息量很大,但通过一些研究,您很快就会发现在您的项目中使用的好策略。