链接微服务并允许其中的一个不可用 [英] linking Microservices and allowing for one to be unavailable

查看:109
本文介绍了链接微服务并允许其中的一个不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是微服务体系结构的新手,并且看到在该模型下可以通过HTTP请求从另一个服务调用微服务.但是,我读到,如果一项服务出现故障,所有其他服务仍应运行. 我的问题是,这通常是如何实现的?

I'm new to the microservices architecture and am seeing that it is possible under the model to call a microservice from another via HTTP request. However, I am reading that if a service is down all other services should still operate. My question is, how is this generally achieved?

例如,处理所有Car记录操纵的微服务可能需要访问处理Vehicle数据的服务.如果汽车微服务中断或无法响应,如何完成其​​操作?

Example, a microservice that handles all Car record manipulation may need access to the service which handles the Vehicle data. How can the Car Microservice complete it's operations if that service is down or doesn't respond?

推荐答案

您通常应该考虑微服务之间的几乎零同步通信(如果仍然要进行同步通信,请尝试考虑使您的服务能够响应但具有逻辑性的断路器错误消息(如果没有断路时使用的相关服务也将完全关闭).这可以通过质疑micorservice的一致性要求来实现.

You should generally consider almost zero sync communication between microservices(if still you want sync comminucation try considering circuit breakers which allow your service to be able to respond but with logical error message , if no circuit breaking used dependent services will also go down completly).This could be achieved by questioning the consistency requirement of the micorservice.

有时这些东西不是直接可见的,例如:假设有两个服务,订单服务和客户服务,而订单服务公开了一个api,该API表示要为客户id下订单.和商家说您不能为未知客户下订单

Sometimes these things are not directly visible , for eg: lets say there are two services order service and customer service and order service expose a api which say place a order for customer id. and business say you cannot place a order for a unknown customer

一种实现是从您称为同步客户服务的订单服务中进行的----在这种情况下,客户服务中断将影响您的服务,现在让我们怀疑我们是否真的需要这样做.

one implementation is from the order service you call the customer service in sync ---- in this case customer service down will impact your service, now lets question do we really need this.

由于可能发生这样的情况:客户刚下了订单,有人从客户服务中删除了该客户,所以现在我们有一个不属于客户的订单.不能保证一致性.

Because a scenario could happen where customer just placed an order and somebody deleted that customer from customer service, now we have a order which dosen't belong to customer.Consistency cannot be guaranteed.

在新的sol中.我们是说允许订单服务在不检查客户ID的情况下下订单,并执行以下操作之一:

In the new sol. we are saying allow the order service to place the order without checking the customer id and do one of the following:

  1. 使用ProcessManager检查客户有效性并将订单状态更新为无效,并在使用ProcessManager删除客户时将订单状态更新为无效或执行业务逻辑
  2. 根本不检查,因为下订单根本不算什么,当此订单在发送过程中,服务将始终检查客户状态

这里声明是试图在微服务之间实现更多的异步通信,大多数情况下您将能够找到sol.符合企业要求的一致性.但是,如果您的企业要对其进行100%的检查,则必须调用其他服务,如果其他服务出现故障,则您的服务会出现逻辑错误.

Statement here is try to achieve more async communication between microservices , mostly you will be able find the sol. in the consistency required by the business. But in case your business wants to check it 100% you have to call other service and if other service is down , your service will give logical errors.

这篇关于链接微服务并允许其中的一个不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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