微服务,客户端发现 [英] Micro-services, client-side discovery

查看:109
本文介绍了微服务,客户端发现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是微服务的新手,因此在阅读它时,在谈论负载平衡时,我无法理解下面的段落,客户端将如何做这样的事情?

I am new to microservices, so while reading about it,I can't understand the below paragraph when talking about the load balancing, how the client will do something like this?

使用客户端发现时,客户端负责确定可用服务实例的网络位置并在它们之间进行负载平衡请求."

"When using client‑side discovery, the client is responsible for determining the network locations of available service instances and load balancing requests across them."

推荐答案

微服务体系结构涉及许多可能具有层次依赖性的服务.例如,服务A依赖于服务B,而服务B依次依赖于服务C,依此类推.同样,每个服务可能有多个实例,并且它们的部署位置可能会动态更改.例如,服务C的点击量过多,您可以动态扩展/缩小该服务.

A Microservice architecture involves a number of services that may have hierarchical dependencies. For example, Service A depends on Service B and Service B in turn depends on Service C and so on. Again, there can be multiple instances of each services and the location at which they are deployed may change dynamically. For example, Service C is getting too many hits and you may dynamically scale up/down this service.

通常,最终用户无法直接访问这些微服务中的任何一个.只能通过位置固定的边缘服务(例如,www.microservice.com/apis)访问它,并将负责进行身份验证,速率限制等.因此,所有服务调用都将通过边缘服务并进行加载此阶段的平衡主要是使用硬件负载平衡器或Amazon ELB实现的.

Usually, an end user cannot access any of these micro-services directly. It can be accessed only through a edge-service whose location is fixed, say www.microservice.com/apis, and will be responsible for doing authentication, rate limiting etc. So, all service calls will go through the edge-service and load balancing at this stage is primarily achieved using a hardware load balancer OR Amazon ELBs.

现在,假设用户要访问服务A.他必须经过边缘服务,该服务会将请求委派给服务A.服务A必须调用服务B以获取一些信息.在这种情况下,服务A是服务B的客户端,服务A需要找到B的所有可用实例,然后调用这些实例之一.这是一个微服务注册表,例如领事

Now, suppose that a user wants to access Service A. He has to go through edge-service which will delegate the request to Service A. Service A has to call Service B to get some information. In this case, Service A is a client of Service B and Service A need to find all the available instances of B and then make a call to one of these instances. This is where a Microservice Registry like Consul,Eureka etc comes into picture. Each service instance will be continuously updating its status (IP, Port, Up/Down etc) to the registry. The edge-service will also be using this registry to find the instance location of Service A.

服务A还应确保对服务B的所有调用均处于负载平衡状态.在这里使用ELB进行负载平衡是不可行的,因为这意味着如果您有50个服务,则需要有50个ELB.有一些软件负载平衡器可以更有效地执行此操作.例如: Ribbon 是一个很好的Http客户端库,具有用Java编写的负载均衡器支持.

Service A should also make sure that all calls to Service B are load balanced. It is not feasible to use ELBs for load-balancing here because it means you need to have 50 ELBs if you have 50 services. There are software load-balancers that can do this in a more effective manner. For eg: Ribbon is a good Http client library with load-balancer support written in Java.

这篇关于微服务,客户端发现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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