本文介绍了Zuul和Ribbon集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难理解Zuul和Ribbon之间的联系.

I have trouble understanding the connection between Zuul and Ribbon.

我想我让Zuul明白了.我可以联系这是一个反向代理来访问我的几个服务实例之一.它会使用循环算法或您配置的服务器来选择合适的服务器.这是传统的负载均衡器.要知道可用的实例,可以使用Eureka之类的注册表.

I think I got Zuul clear. It's a reverse proxy I can contact to reach one of my several instances of a service. It will pick the right server using a round-robin algorithm or whatever you configure it to do. It's a traditional load-balancer. To know the instances available it can use a registry like Eureka.

但是我对Ribbon遇到了更多麻烦.它作为客户端负载平衡器出售,但这是什么意思?不需要外部服务器吗?功能区是否像Eureka客户端一样嵌入在客户端中?如果是这样,它如何运作?使用Ribbon时是否需要Zuul,反之亦然?

But I've got more trouble with Ribbon. It's sold as a client-side load balancer but what does it mean ? It doesn't need an external server ? Ribbon is embedded in the client the same way an Eureka client is ? If so how does it work ? Do I need Zuul when I use Ribbon, and vice-versa ?

在一些文章上,我看到实际上,Zuul默认使用Ribbon作为负载平衡部分,这让我更加困惑.如果这是真的,那么客户端"是什么意思? Zuul除了路由外还做什么?

On some articles, I saw that in fact, Zuul uses Ribbon by default for the load balancing part and it got me even more confused. If this is true what does "client-side" mean ? What does Zuul do except routing ?

希望你能帮助我.

推荐答案

客户端和服务器始终是相对的. Zuul是您的服务实例的客户端,而您的服务实例是Zuul的服务器.

Client and Server is always relative. Zuul is a client for your service instances and your service instances are servers for Zuul.

当我们使用传统的负载平衡器(服务器端负载平衡器)时,API调用程序(客户端)仅知道一个端点,即负载平衡器,而客户端则不知道服务器列表.负载均衡器从列表中选择服务器.

When we are using traditional load balancer (server-side load balancer), API caller (client) only knows a single endpoint that is a load balancer and the client doesn't know the list of servers. Load balancer chooses a server from the list.

当我们使用像Ribbon一样的客户端负载平衡器时,API调用者(客户端)应该知道服务器列表,并从列表中选择其中之一.这就是为什么我们称其为客户端负载均衡器.

When we are using client-side load balancer like Ribbon, API caller (client) should know the list of servers and choose one of them from the list. That's why we call it client-side load balancer.

您知道,Ribbon是一个客户端负载平衡器模块,并且已集成到许多http客户端模块中.例如,假装和负载平衡的RestTemplate支持功能区.即Feign和负载平衡的RestTemplate在与功能区一起使用时可以从给定列表中选择服务器,也可以从eureka中选择列表.

As you know, Ribbon is a client-side load balancer module and is integrated to many http client modules. As an example, Feign and Load-balanced RestTemplate support Ribbon. Namely Feign and Load-balanced RestTemplate can choose a server from the given list or the list from eureka when used with ribbon.

关于Zuul,有一个RibbonRoutingFilter会将您的请求路由到实际的服务实例. RibbonRoutingFilter正在使用Ribbon从您的配置或Eureka给出的列表中选择服务器.因此,如果要使用Zuul作为负载平衡的反向代理,Zuul需要功能区.

Regarding Zuul, there is a RibbonRoutingFilter that routes your request to an actual service instance. RibbonRoutingFilter is using Ribbon to choose a server from the list that is given from your configuration or from Eureka. So if you want to use Zuul as a load-balanced reverse proxy, Zuul needs Ribbon.

这篇关于Zuul和Ribbon集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 07:55