SpringCloudRibbon client load balancing

Author: Zen and the Art of Computer Programming

1 Introduction

  Spring Cloud Ribbon is an important module of Spring Cloud. It is a client load balancer based on Netflix Ribbon. Ribbon is an excellent set of REST-based service call load balancing components open sourced by Netflix. Through Ribbon, service calls based on protocols such as HTTP and TCP can be integrated in the cloud, thereby improving the elastic scalability of cloud applications and reducing the dependence on cloud resources. This article will combine specific examples to elaborate on the working principle of Spring Cloud Ribbon, and give solutions based on examples. # 2. Explanation of basic concepts and terms First, you need to understand some related basic knowledge. After understanding the basic principles of Ribbon, you can better understand Spring Cloud Ribbon. ### 2.1 Basic principle of Ribbon Ribbon is a set of REST-based service call components developed by Netflix engineers. It supports multiple protocols such as HTTP, HTTPS, TCP, DNS, etc. By using the Ribbon, you can send a request to a specific target service and get the response results of multiple service instances (Server). In the process of load balancing, Ribbon will automatically select the best server for communication, so as to avoid single point of failure to the greatest extent. As shown below:

    ![img](https://pic1.zhimg.com/v2-d9b72c45aaabbbdc77f7a21d40d4e4ee_r.jpg)

     在 Ribbon 中,我们通常将服务注册中心作为第一步,在其中定义了各个服务的实例地址及其他元数据信息,比如可用状态、版本号等。然后,Ribbon 会从中获取相应的服务实例列表,并根据负载均衡策略选择其中一个实例进行调用。Ribbon 提供了丰富的负载均衡策略,包括轮询、随机加权、区域感知等。Ribbon 默认采用的是轮询的方式进行负载均ahlancing。轮询模

Guess you like

Origin blog.csdn.net/universsky2015/article/details/132002527