For businesses that are highly sensitive to RT, during tenant scaling, it is necessary to strictly limit the load balancing operations on the nodes where the log stream leaders are located. These load balancing operations include transfer tasks, log stream replica migration and replication, and leader handover. In this case, heterogeneous zones can be used to avoid leader handover and leader replica migration during peak business hours, making the entire scaling process smoother.
Considerations
In general, only the Zone with a changed UNIT_NUM value will have log stream migration during scaling or rollback operations. Other Zones will only have local transfers. However, if the tenant is not in a balanced state before initiating a scaling operation, such as during partition balancing or if a new scaling task is started before the previous one is completed, the system cannot guarantee that log streams will not be migrated to other Zones.
Scenario 1: Scale out or in by adding or removing zones
If the PRIMARY_ZONE of a tenant is spread across multiple zones and cannot be concentrated in a single zone, you need to use the locality change method to scale out or in. This involves first adding or removing zones, then using the locality change method to add replicas to the new zones. The process of adding replicas ensures a balanced distribution.
Let's take scaling out as an example.
Scenario 1: Expand the number of units
Assume that you have a tenant named tenant1. The Locality of tenant1 is F@zone1, F@zone2, A, and the PRIMARY_ZONE is zone1, zone2. Tenant1 has a resource pool named pool that is distributed across zone1 and zone2. The UNIT_NUM is 2 (i.e., the UNIT_NUM is set to 2:2). The distribution of user log streams is shown in the following figure.
You need to expand the UNIT_NUM of the resource pool of tenant1 to 4:4.
Procedure
Log in to the
systenant of the cluster as therootuser.Disable the
enable_ls_leader_balanceparameter.The tenant-level parameter enable_ls_leader_balance is the switch for log stream leader balancing. When the automatic load balancing switch
enable_rebalanceis enabled, this parameter can be used to independently control the automatic balancing of log stream leaders. The default value isTrue, which indicates that automatic balancing of log stream leaders is enabled by default.obclient(root@sys)[(none)]> ALTER SYSTEM SET enable_ls_leader_balance = False TENANT = 'tenant1';Add two zones with four nodes each and add resources for tenant1 in the new zones.
Add two zones, zone3 and zone4, to the cluster. For more information, see Add a zone.
Add four nodes to each of the newly added zones, zone3 and zone4. For more information, see Add a node.
Create a resource pool named
pool2in the newly added zones, zone3 and zone4. The specifications of the new resource pool must be the same as those of the original resource pool, and the UNIT_NUM must be set to 4.obclient(root@sys)[(none)]> CREATE RESOURCE POOL pool2 UNIT='unit_name', UNIT_NUM = 4, ZONE_LIST=('zone3','zone4');In the preceding statement, replace
unit_namewith the actual unit name.Modify the resource pool of tenant1 to allocate the newly added resource pool
pool2to tenant1.obclient(root@sys)[(none)]> ALTER TENANT tenant1 RESOURCE_POOL_LIST =('pool','pool2');After the preceding statement is executed, the UNIT_NUM of tenant1 is 2:2:4:4 across
zone1,zone2,zone3, andzone4.
Modify the Locality of tenant1 to add the newly added zones, zone3 and zone4, to the Locality.
Change the Locality from
F@zone1, F@zone2, AtoF@zone1, F@zone2, F@zone3, F@zone4, A. The statement is as follows:obclient(root@sys)[(none)]> ALTER TENANT tenant1 LOCALITY="F@zone1,F@zone2,F@zone3,F@zone4,A";After the preceding statement is executed, the system automatically fills the log stream replicas on the newly added units and evenly distributes them across all units. In this process, only Follower replicas are added, so no leader switching occurs.
The distribution of user log streams is shown in the following figure.
Modify the
PRIMARY_ZONEof tenant1 to the newly added zones, zone3 and zone4, and enable theenable_ls_leader_balanceparameter.Change the
PRIMARY_ZONEfromzone1, zone2tozone3, zone4. The statement is as follows:obclient(root@sys)[(none)]> ALTER TENANT tenant1 PRIMARY_ZONE='zone3,zone4';Enable the
enable_ls_leader_balanceparameter. The statement is as follows:obclient(root@sys)[(none)]> ALTER SYSTEM SET enable_ls_leader_balance = True TENANT = 'tenant1';After the preceding statements are executed, the leader replicas of all log streams are automatically switched to
zone3andzone4. If you only change thePRIMARY_ZONEof log streams, the process is fast and the impact is controllable.Modify the Locality of tenant1 to remove
zone1andzone2from the Locality.Change the Locality from
F@zone1, F@zone2, F@zone3, F@zone4, AtoF@zone3, F@zone4, A. The statement is as follows:obclient(root@sys)[(none)]> ALTER TENANT tenant1 locality="F@zone3,F@zone4,A";After the preceding statement is executed, the replicas of log streams in
zone1andzone2are deleted, but those inzone3andzone4are not affected.Modify the resource pool of tenant1 to remove the original resource pool
pooland retain only the newly added resource poolpool2.obclient(root@sys)[(none)]> ALTER TENANT tenant1 RESOURCE_POOL_LIST =('pool2');After the original resource pool
poolis removed from tenant1, the two-nodezone1andzone2can also be deleted.After the preceding operations are completed, only
zone3andzone4with four nodes (UNIT_NUMof 4) remain in the current tenant. The expansion is completed.
Scenario 2: In-place expansion or contraction
For a tenant with a concentrated PRIMARY_ZONE, you can perform in-place expansion or contraction. In-place expansion or contraction ensures that only the zones that host Follower replicas are modified.
The following example describes how to perform in-place expansion.
Scenario information
Assume that you have a tenant named tenant1. The Locality of tenant1 is F@zone1, F@zone2, A, and the PRIMARY_ZONE is zone1. Tenant1 has a resource pool named pool that is distributed across zone1 and zone2. The UNIT_NUM is 2 (i.e., the UNIT_NUM is set to 2:2). The distribution of user log streams is shown in the following figure.
You need to expand the UNIT_NUM of the resource pool of tenant1 to 4:4.
Procedure
Log in to the
systenant of the cluster as therootuser.Split the resource pool of the tenant into
pool1inzone1andpool2inzone2.obclient(root@sys)[(none)]> ALTER RESOURCE POOL pool SPLIT INTO ('pool1','pool2') ON ('zone1','zone2');For more information about how to split a resource pool, see Merge and split resource pools.
Change the
UNIT_NUMof the split resource poolpool2to 4.obclient(root@sys)[(none)]> ALTER RESOURCE POOL pool2 UNIT_NUM = 4;After the statement is executed, the log stream is automatically split and distributed to 4 units in
zone1. The distribution of the user log stream is as follows.Change the
PRIMARY_ZONEof the tenant tozone2.obclient(root@sys)[(none)]> ALTER TENANT tenant1 PRIMARY_ZONE='zone2';Change the
UNIT_NUMof the split resource poolpool1to 4.obclient(root@sys)[(none)]> ALTER RESOURCE POOL pool1 UNIT_NUM = 4;After the statement is executed, the system starts to balance the resources. After the balancing is completed, the expansion is completed. The distribution of the user log stream is as follows.
(Optional) If you want the leader replicas to remain concentrated in
zone1, change thePRIMARY_ZONEof the tenant back tozone1.obclient(root@sys)[(none)]> ALTER TENANT tenant1 PRIMARY_ZONE='zone1';
