Microservices are the most important building blocks of Cloud-Native architectures. Microservice instances are scaled up and down based on the load of a specific microservice. How do we ensure that the load is equally distributed among the different instances of microservices? That's where the magic of load balancing comes in. Load balancing is important in order to ensure that the load is equally distributed among the different instances of microservices.
As shown in the following figure, Spring Cloud Netflix Ribbon provides client-side load balancing using round robin execution among the different instances of a microservice:
We will add Ribbon to service consumer microservice. The service consumer microservice will distribute the load among two instances of Microservice A.
Let's start with adding the Ribbon dependency to the pom.xml
file of service consumer microservice:
<dependency> <groupId>org.springframework.cloud</groupId>...