Load Balance Algorithm
Background
ShardingSphere built-in provides a variety of load balancer algorithms, including polling algorithm, random access algorithm and weight access algorithm, which can meet users’ needs in most business scenarios.
Moreover, considering the complexity of the business scenario, the built-in algorithm also provides an extension mode. Users can implement the load balancer algorithm they need based on SPI interface.
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
- Configure a load balancer algorithm for the loadBalancers attribute to use read/write splitting.
Sample
rules:
- !READWRITE_SPLITTING
dataSources:
readwrite_ds:
writeDataSourceName: write_ds
readDataSourceNames:
- read_ds_0
- read_ds_1
transactionalReadQueryStrategy: PRIMARY
loadBalancerName: random
loadBalancers:
random:
type: RANDOM
Related References
当前内容版权归 ShardingSphere 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 ShardingSphere .