且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

微服务、amqp 和服务注册/发现

更新时间:2023-02-26 21:27:12

AMQP(实际上是任何 MOM)为进程提供了一种通信方式,而无需考虑实际的 IP 地址、通信安全、路由等问题.这并不一定意味着任何进程都可以信任或什至拥有与其通信的进程有关的任何信息.

AMQP (any MOM, actually) provides a way for processes to communicate without having to mind about actual IP addresses, communication security, routing, among other concerns. That does not necessarily means that any process can trust or even has any information about the processes it communicates with.

消息队列确实解决了一半的过程:如何到达远程服务.但他们没有解决另一半:哪种服务适合我.换句话说,哪个服务:

Message queues do solve half of the process: how to reach the remote service. But they do not solve the other half: which service is the right one for me. In other words, which service:

  • 有我需要的资源
  • 可以信任(托管在可靠的服务器上,具有令人满意的服务实施,位于当地法律符合您要求的国家/地区等)
  • 收取您想支付的费用(尽管人们很少讨论微服务的成本)
  • 将在处理您的服务所需的整个时间窗口内都在那里——请记住,服务器变得越来越不稳定.有些服务器实际上是可以持续几分钟的容器.

这两个问题几乎是线性无关的.为了解决第二类问题,您需要在网格计算中使用资源代理.还有资源分配,以确保正确管理上述最后一项.

Those two problems are almost linearly independent. To solve the second kind of problems, you have resource brokers in Grid computing. There is also resource allocation in order to make sure that the last item above is correctly managed.

有一些替代策略,例如多播使用服务的意图并等待报价的回复.例如,您可能会在这种情况下进行反向拍卖.

There are some alternative strategies such as multicasting the intention to use a service and waiting for replies with offers. You may have reverse auction in such a case, for instance.

简而言之,经验法则是,如果您对要使用的服务(硬编码或在某些配置文件中)没有先验知识,则您的代理将必须进行协商,其中包括动态服务发现.

In short, the rule of thumb is that if you do not have an a priori knowledge about which service you are going to use (hardcoded or in some configuration file), your agent will have to negotiate, which includes dynamic service discovery.