Load balancing strategy
Load Balance (Load Balance), in fact, is to allocate requests to multiple operation units for execution, so as to complete work tasks together.
To put it simply, there are a lot of servers, and one server should not always work.
Dubbo provides a total of 4 strategies. The default is random.
Modify the provider configuration and start 3 providers to allow consumers to access them
- tomcat port 8001, 8002, 8003
-
provider port 20881, 20882, 20883
<dubbo:provider timeout="2000" port="20883"/>
-
HelloServiceImpl01 class, server 1, server 2, server 3
System.out.println("------------服务器3---2.0-----no被调用1此--------------");
-
Start the consumer for testing
Consumer modification weight
<!--loadbalance="roundrobin":负载均衡策略-->
<dubbo:reference loadbalance="roundrobin" interface="service.HelloService" id="helloService" version="2.0.0" stub="stub.HelloServiceStub">
<dubbo:method name="sayHello" retries="3"></dubbo:method>
<dubbo:method name="sayNo" retries="0"></dubbo:method>
</dubbo:reference>
It is best to use the management terminal to modify the weight