[Spring Cloud]-Zuul Practice (2)-Load Balancing

Posted May 27, 20201 min read

Zuul's internal load balancing through Ribbon.
For the first contact, you don't need to know too much, or the old way, go to the demo.

The demo involved in this article is based on the first lesson of zuul: \ [Spring Cloud ]-Zuul Practice(1)-Basic Use , it is recommended Read the first lesson(you can also read this article directly, this article is easy to understand, suitable for all ages).

Zuul load balancing is implemented on the premise of multiple instances of the same service. In layman's terms, connecting multiple same services in eureka server is the premise of Zuul load balancing.

  1. We create two different projects, which set the same application.name. The creation steps are not repeated, please refer to my other document \ [Spring Cloud ]-Eureka Creation and Use to create eureka client.
    Note:Make sure that the spring.application.name of the configuration files in the two projects are the same.

     spring:
       application:
         name:service1
  2. Start the two projects and check whether two identical services are registered in the eureka server:(Availability Zones number is the number of service copies)![Image.png]( https://i0.wp.com/segmentfault .com/img/bVbHFiY "image.png")

  3. If you use zuul to access service1 at this time, zuul will automatically distribute the request to these two same services.

The above is the most basic load balancing function based on zuul and eureka. Is it simple?