How it works...

Client-side load balancing is a feature of a client application that decides where to assign the request transactions during traffic and server problems. This solution was formulated when the architectural concepts of SOA and microservices became foundations of software architecture and during the popularity of failover and backup and recovery in the hardware technology. The fusion between the two different techniques provided a way to build a resilient, fault-tolerant, and load sharing microservice architecture.

With or without Eureka service discovery, Spring Cloud Netflix Ribbon is always this simple inter-process communication solution that aims to implement client-side load balancing with its set of algorithms. In this recipe, a Eureka client has been used as the specimen in applying Ribbon's LoadBalancerClient to choose the healthiest microservice instance without specifying the exact IP address and port. The annotation @LoadBalanced has been used also to configure the RestTemplate and AsyncRestTemplate to apply also the load balancing algorithm. Using Ribbon with a Eureka server is much easier and more straightforward than with the non-Eureka client which requires the addition of the @RibbonClient(name="custom_service_name") to the bootstrap class and the registration of all the mapping of this custom_service_name to multiple instances to its application.properties file:

custom_service_name.ribbon.eureka.enabled=false 
custom_service_name.ribbon.listOfServers=localhost:8094/ch10-dept1,localhost:8095/ch10-dept2 

This Ribbon module of Spring Cloud Finchley dependencies supports synchronous, asynchronous and reactive microservice instances built by Spring Boot 2.0 release.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.98.148