Automatic load balancing for partition replicas is intended to adjust the distribution of partition replicas among resource units of a tenant to minimize the load difference between the resource units. Automatic load balancing for partition replicas is a tenant-level action that occurs within a single zone. RootService migrates data replicas of a tenant among resource units within a zone to achieve load balancing for the resource units.
Load balancing groups
Partition replica balancing is intended to evenly schedule all partitions of a tenant in a single zone to all resource units in the zone. During partition replica balancing for a zone, OceanBase Database divides all partitions in the zone into multiple groups. Each group is a basic unit for balanced scheduling and called a load balancing group. A load balancing group is a collection of partitions. Load balancing groups are independent of each other. When load balancing is achieved for partitions in each load balancing group, OceanBase Database considers that overall load balancing is achieved for all partitions in the zone.
OceanBase Database supports the following three types of load balancing groups:
Type 1 load balancing group: contains all partitions of a table group that consists of multiple partitions.
Type 2 load balancing group: contains all partitions of a multi-partition table that does not belong to any table group.
Type 3 load balancing group: contains all partitions other than those in type 1 and type 2 load balancing groups. A tenant can have only one type 3 load balancing group in each zone.
Load balancing rules
In OceanBase Database, you can set the balancer_tolerance_percentage parameter to specify the sensitivity of disk load balancing. The parameter value is a percentage within the range of [1, 100].
Load balancing rules for different types of load balancing groups based on the balancer_tolerance_percentage parameter:
Type 1 load balancing group
All partitions in a type 1 load balancing group come from one table group. Such a load balancing group is intended to evenly schedule partition groups to all resource units in a zone so that the difference between the numbers of partition groups in all resource units is not greater than 1. While ensuring that the number of partition groups meets the requirement, OceanBase Database migrates partition groups among resource units to make the difference between disk usages of the resource units less than the value of the
balancer_tolerance_percentageparameter.For more information about partition groups, see Table groups.
Type 2 load balancing group
All partitions in a type 2 load balancing group come from one multi-partition table. Such a load balancing group is intended to evenly schedule all partitions of the multi-partition table to all resource units in a zone so that the difference between the numbers of partitions in all resource units is not greater than 1. While ensuring that the number of partitions meets the requirement, OceanBase Database migrates partitions among resource units to make the difference between disk usages of the resource units less than the value of the
balancer_tolerance_percentageparameter.Type 3 load balancing group
A type 3 load balancing group contains all partitions other than those in type 1 and type 2 load balancing groups. OceanBase Database evenly schedules these partitions to all resource units in a zone so that the difference between the numbers of partitions in all resource units is not greater than 1. While ensuring that the number of partitions meets the requirement, OceanBase Database migrates partitions among resource units to make the difference between disk usages of the resource units less than the value of the
balancer_tolerance_percentageparameter.