Dubbo load balancing strategy configuration

Load balance strategy LoadBalance 

  • RandomLoadBalance: Random strategy. Set the weight according to the probability, which is more uniform, and the weight of the provider can be dynamically adjusted.
  • RoundRobinLoadBalance: Polling strategy. Polling, set the polling ratio according to the weight after the convention. There will be cases where slow-executing service providers accumulate requests. For example, a machine executes very slowly, but the machine does not hang up the call (if it hangs, then the current machine will be deleted from the Zookeeper service list), when many new requests arrive After the machine, because the previous requests have not been processed, new requests will be piled up. Over time, all consumer calls on this machine will be blocked.
  • LeastActiveLoadBalance: The least number of active calls. If the active number of each provider is the same, one is randomly selected. In each service provider, an active counter is maintained to record the number of simultaneous processing requests, that is, the number of concurrent processing tasks. Therefore, if this value is smaller, the processing speed of the current service provider is fast or the load of the current machine is relatively low, so the machine with the least activity is selected when routing. If a service provider's processing speed is very slow, due to accumulation, then more requests are processed at the same time, that is, the greater the number of active calls, this also makes the slower provider receive fewer requests, because the slower the provider The activity is getting bigger and bigger.
  • ConsistentHashLoadBalance: Consistent Hash strategy. Consistent Hash can ensure that requests with the same parameters are always sent to the same provider. When a provider hangs up, the request originally sent to that provider will be spread to other providers based on the virtual node. Cause dramatic changes.

Configuration instructions

  • Solution configuration method, first use consumer configuration
<!--服务端配置-->
<dubbo:service loadbalance="random"/>
<!--消费端配置-->
<dubbo:reference loadbalance="random"/>

Random Strategy-RandomLoadBalance

<!--
weight:权重为5
-->
<dubbo:service loadbalance="random" weight="5"/>

Polling Strategy-RoundRobinLoadBalance

<!--
weight:权重为5
-->
<dubbo:service loadbalance="roundrobin" weight="5"/>

Minimum number of active calls-LeastActiveLoadBalance

<!--
weight:权重为5
-->
<dubbo:service loadbalance="leastactive" weight="5"/>

Consistent Hash Strategy-ConsistentHashLoadBalance

<!--
-->
<dubbo:service loadbalance="consistenthash"/>

 

Guess you like

Origin blog.csdn.net/lizz861109/article/details/98808144
Recommended