{% include toc %} Flow control mechanism controls the transmission speed to avoid microservices being overloaded. This guide shows how to use flow control with ServiceComb in the BMI application.
Walk through Develop microservice application in minutes and have BMI application running.
Add flow control dependency in pom.xml
of BMI calculator service:
<dependency> <groupId>org.apache.servicecomb</groupId> <artifactId>handler-flowcontrol-qps</artifactId> </dependency>
Add handler chain and configurations of flow control in microservice.yaml
of BMI calculator service:
servicecomb: handler: chain: Provider: default: qps-flowcontrol-provider flowcontrol: Provider: qps: limit: gateway: 1
The above configurations have already set up in the code. All you need to do is to stop all BMI calculator services and then start a new one with the following command:
#spring-boot-maven-plugin 1.x mvn spring-boot:run -Drun.jvmArguments="-Dcse.handler.chain.Provider.default=qps-flowcontrol-provider -Dcse.flowcontrol.Provider.qps.limit.gateway=1"
or
#spring-boot-maven-plugin 2.x mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Dcse.handler.chain.Provider.default=qps-flowcontrol-provider -Dcse.flowcontrol.Provider.qps.limit.gateway=1"
Visit http://localhost:8889. Input a positive height and weight and then click Submit button twice or more in less than one second. You will see the web page change from the left one to the right one.
{: .align-center}
See quick start for Service Management
Learn more about Flow Control