Retro Eye care Haitian Deep Dark Default

Load Balance Algorithm

Background

ShardingSphere provides built-in load balancer algorithms, including polling algorithm, random access algorithm and weight access algorithm. Users can implement the corresponding SPI to provide a custom load balancer algorithm for complex business scenarios.

Parameters

Round-robin Load Balance Algorithm

Type: ROUND_ROBIN

Random Load Balance Algorithm

Type: RANDOM

Weight Load Balance Algorithm

Type: WEIGHT

Attributes:

Name DataType Description
${replica-name} double Attribute name uses the name of the replica, and the parameter fills in the weight value corresponding to the replica. Weight parameter range min > 0, total <= Double.MAX_VALUE.

Procedure

  1. Configure a load balancer algorithm for the loadBalancers attribute to use read/write splitting.

Sample

rules:
- !READWRITE_SPLITTING
  dataSourceGroups:
    readwrite_ds:
      writeDataSourceName: write_ds
      readDataSourceNames:
        - read_ds_0
        - read_ds_1
      transactionalReadQueryStrategy: PRIMARY
      loadBalancerName: random
  loadBalancers:
    random:
      type: RANDOM