To implement vertical scaling of resources in a tenant, you can adjust the unit config of the resource pools allocated to the tenant to adjust the service capability of the tenant. To adjust the unit config of a resource pool, you can either modify or switch the unit config.
Modify the unit config
You can modify the unit config, that is, directly modify the CPU and memory resource configurations in the unit config, of a resource pool to adjust the service capability of the tenant to which the resource pool is allocated.
Assuming that resource pools pool1 and pool2 are created, and both of them use the resource config uc1. You can adjust the resource config uc1 by modifying the maximum CPU and memory size of the resource pools. Specifically, set MAX_CPU to 6 and MEMORY_SIZE to 36G, and leave other options unchanged. The example statement is as follows:
obclient> CREATE RESOURCE UNIT uc1 MAX_CPU 5, MIN_CPU 4, MEMORY_SIZE '36G', MAX_IOPS 10000, MIN_IOPS 10000, LOG_DISK_SIZE = '108G';
obclient>CREATE RESOURCE POOL pool1 UNIT 'uc1', UNIT_NUM 2, ZONE_LIST ('z1', 'z2');
obclient>CREATE RESOURCE POOL pool2 UNIT 'uc1', UNIT_NUM 1, ZONE_LIST ('z3');
obclient>CREATE TENANT tt resource_pool_list=('pool1','pool2');
obclient>ALTER RESOURCE UNIT uc1 MAX_CPU 6, MEMORY_SIZE '36G';
You can modify resource parameters to adjust the unit config of the resource pools for a tenant in the corresponding zone, so as to adjust the service capability of the tenant.
Switch the unit config
You can switch the unit config of each resource unit in a resource pool to adjust the service capability of the tenant to which the resource pool is allocated.
Assume that the resource pool rp1 originally uses the unit config uc1. You can switch the unit config of the resource pool rp1 from uc1 to uc2.
obclient> ALTER RESOURCE POOL rp1 UNIT 'uc2';
Examples and limitations
Generally, you can either modify or switch the unit config to adjust the service capability of a tenant. This, in essence, is realized by adjusting the specifications of resource units used by the tenant. When you modify the unit config, you can either upgrade or downgrade the unit config.
Upgrade the unit config
Unit config upgrade mainly applies for resource scale-out in a tenant. You can respectively scale out CPU and memory resources.
Here are some examples:
Example 1
- Create unit config
u_c0and resource poolpool1, and then applyu_c0topool1.
obclient> CREATE RESOURCE UNIT u_c0 MAX_CPU 5, MIN_CPU 4, MEMORY_SIZE '36G', MAX_IOPS 10000, MIN_IOPS 10000, LOG_DISK_SIZE = '108G'; obclient> CREATE RESOURCE POOL pool1 unit='u_c0', unit_num=3, zone_list=('z1','z2','z3');- Increase the value of the
MIN_CPU,MAX_CPU, andMEMORY_SIZEparameters inu_c0.
obclient> ALTER RESOURCE UNIT u_c0 MAX_CPU 10, MIN_CPU 8, MEMORY_SIZE '72G';The adjustment is intended to upgrade the unit config of `pool1` and thereby enhance the service capability of the corresponding tenant.- Create unit config
Example 2
- Create unit configs
u_c0andu_c1and resource poolpool1, and then applyu_c0topool1.
obclient> CREATE RESOURCE UNIT u_c0 MAX_CPU 5, MIN_CPU 4, MEMORY_SIZE '36G', MAX_IOPS 10000, MIN_IOPS 10000, LOG_DISK_SIZE = '108G'; obclient> CREATE RESOURCE UNIT u_c1 MAX_CPU 10, MIN_CPU 8, MEMORY_SIZE '72G', MAX_IOPS 10000, MIN_IOPS 10000, LOG_DISK_SIZE = '216G'; obclient> CREATE RESOURCE POOL pool1 unit='u_c0', unit_num=3, zone_list=('z1','z2','z3');Switch the unit config of
pool1tou_c1.obclient> ALTER RESOURCE POOL pool1 unit='u_c1';The adjustment is intended to upgrade the unit config of
pool1and thereby enhance the service capability of the corresponding tenant.
- Create unit configs
Regardless of whether you modify or switch the unit config, the total resources after the adjustment must meet the following requirements:
Sum(min_cpu) <= CPU_CAPACITY;
Sum(memory_size) <= MEM_CAPACITY;
Sum(max_cpu) <= CPU_CAPACITY * resource_hard_limit;
Otherwise, the system returns an error, indicating that the operation fails.
Downgrade the unit config
OceanBase Database also allows you to downgrade the unit config of a resource pool while ensuring sufficient server resources. When you decrease the value of the MEMORY_SIZE parameter, note that: The MEM_USED parameter indicates the actual memory usage of a tenant on an OBServer node, so make sure that the new value of the MEMORY_SIZE parameter for each OBServer node that serves the tenant is greater than or equal to the value of the MEM_USED parameter. Otherwise, the adjustment fails. If this is the case, you must perform a minor compaction to release the memory, and then attempt to downgrade the unit config of the resource pool again.