Distributed RPC architecture: Dubbo application architecture analysis! Load balancing with Dubbo

Time:2021-11-30

Dubbo application architecture

在这里插入图片描述

  • (init) in Dubbo containerContainerMedium startstartProvider on containerProvider
  • (init) providerProviderregisterregisterService to registryRegistry
  • (init) consumerConsumerFrom registryRegistrysubscribesubscribeservice
  • (async) registryRegistryTo consumersConsumernoticenotify
  • (sync) consumerConsumercallinvokeService providerProvider
  • (async) monitoring centerMonitorMonitoring service consumersConsumerAnd service providersProviderUsage, statisticscountNumber of service requests

Dubbo load balancing

  • During cluster load balancing, Dubbo provides a variety of load balancing strategies,The default is random call,You can also customize the load balancing policy

Load balancing strategy

Random LoadBalance
  • Random load balancing call:Set random probability by weight
  • The higher the probability of collision on an interface, the greater the adjustment amount, the more uniform the distribution, and the more uniform the weight is used according to the probability, which is conducive to the dynamic adjustment of the provider’s weight
RoundRobin LoadBalance
  • Polling load balancing calls:Set the polling ratio according to the weight after the Convention
  • There is a problem of slow providers accumulating requests: when the second machine is slow but does not hang up, it will get stuck when requesting the second machine, resulting in all requests getting stuck on the second machine
LeastActive LoadBalance
  • Minimum number of active calls load balancing calls:Random with the same active number. The active number refers to the count difference before and after the call
  • Make the slow provider receive fewer requests, because the slower the provider, the greater the count difference before and after the call
ConsistentHash LoadBalance
  • Consistent hash load balancing call:Requests for the same parameters are always sent to the same provider
  • When a provider hangs up, the requests originally sent to the provider are shared among other providers based on the virtual node, without causing drastic changes
  • Only the first parameter hash is used by default. If you want to modify it, configure it
  • 160 virtual nodes are used by default. If you want to modify them, configure them

Load balancing configuration

  • Server service level
  • Client service level
  • Server method level
  • Client method level