Logo
Read/write Splitting Algorithm

Read/write Splitting Algorithm #

Round Robin Algorithm #

Type:ROUND_ROBIN

Within a transaction, read requests are routed according to the configuration of the transaction-read-query-strategy property. Out-of-transaction, the Round Robin strategy is used to route to the replica

Configurable properties:

| Property Name Data | Type | Description| | transaction-read-query-strategy | String | Within-transaction read request routing strategy, optional values: FIXED_PRIMARY (route to primary), FIXED_REPLICA (select a fixed replica according to the Round Robin strategy), DYNAMIC_REPLICA (route to different replica according to the Round Robin strategy), default value: FIXED_PRIMARY. |

Random Access Algorithm #

Type: RANDOM

Within a transaction, read requests are routed according to the configuration of the transaction-read-query-strategy property. Out-of-transaction, they are routed to the replica using a random strategy.

Configurable properties:

| Property Name Data | Type | Description| |transaction-read-query-strategy |String |Within-transaction read request routing strategy, optional values: FIXED_PRIMARY (route to primary), FIXED_REPLICA (select a fixed replica according to the Round Robin strategy), DYNAMIC_REPLICA (route to different replica according to the Round Robin strategy), default value: FIXED_PRIMARY.|

Delayed Access Algorithm #

Type: SPHERE_EX_DELAY_REPLICA

Configurable properties: None

Weight Access Algorithm #

Type: WEIGHT

Configurable properties:

All read bases in use must be configured with weights

| Property Name Data | Type | Description| |${replica-name} |double |The property name uses the read base name and the parameter fills in the weight value corresponding to the read base. The weight parameter ranges from minimum > 0 to total <= Double.MAX_VALUE. | |transaction-read-query-strategy |String |Within-transaction read request routing strategy, optional values: FIXED_PRIMARY (route to primary), FIXED_REPLICA (select a fixed replica according to the Round Robin strategy), DYNAMIC_REPLICA (route to different replica according to the Round Robin strategy), default value: FIXED_PRIMARY. |

Procedure #

  1. When using read-write splitting, the corresponding load balancing algorithm is configured under the loadBalancers property.

Configuration Example

copyrules:
- !READWRITE_SPLITTINGdataSources:
    readwrite_ds:
      staticStrategy:
        writeDataSourceName: write_dsreadDataSourceNames:
          - read_ds_0
          - read_ds_1loadBalancerName: randomloadBalancers:
    random:
      type: RANDOMprops:
        transaction-read-query-strategy: FIXED_PRIMARY