Load Balance
When we scale up BMI calculator service, requests from BMI web service need to distribute equally to each BMI calculator service. This guide shows how to use load balance with ServiceComb in the BMI application.
Before you start
Walk through Develop microservice application in minutes and have BMI application running.
Enable
The simple embedded load balancer will be used by default. No extra configurations needed.
Verification
Run one more BMI calculator service with the following command:
#spring-boot-maven-plugin 1.x
mvn spring-boot:run -Drun.jvmArguments="-Dcse.rest.address=0.0.0.0:7778"
or
#spring-boot-maven-plugin 2.x
mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Dcse.rest.address=0.0.0.0:7778"
To better distinguish different running instances, we added a new interface that returns instance id in the implementation of BMI calculator, details can refer to the implementation of BMI calculator. Besides, a different service port is needed to avoid port conflict.
Now you can see the instance id in the following figures shows up alternately by clicking the Submit button.
What’s next
-
See quick start for Flow Control
-
Learn more about Load Balance