You can use any of the following two methods to set the memory limit of ApsaraDB for OceanBase:
Use the memory_limit_percentage parameter to set the percentage of server memory in proportion to the total memory.
Use the memory_limit parameter to set the memory limit of ApsaraDB for OceanBase. If the value of the memory_limit parameter is 0, the value of the memory_limit_percentage parameter takes effect. If the value of the memory_limit parameter is not 0, the memory limit of ApsaraDB for OceanBase is set to this value.
For example, an OceanBase instance is hosted on ECS and has 100 GB memory. The following table lists the memory configurations.
|Scenario||memory_limit_percentage||memory_limit||Memory limit of ApsaraDB for OceanBase|
|Scenario 1||80||0||80 GB|
|Scenario 2||80||90 GB||90 GB|
In scenario 1, the value of the memory_limit parameter is 0. Therefore, the value of the memory_limit_percentage parameter takes effect and the memory limit of ApsaraDB for OceanBase is 80 GB (100 GB × 80% = 80 GB).
In scenario 2, the value of the memory_limit parameter is 90 GB, and the memory limit of ApsaraDB for OceanBase is 90 GB.
ApsaraDB for OceanBase is a database system that supports multitenancy. However, ApsaraDB for OceanBase cannot allocate all its memory to tenants. Tenants on each OBServer share resources or features. The memory that is consumed by these resources or features is not owned by a single tenant. This portion of memory is known as system memory. You can use the system_memory_percentage parameter to set the maximum percentage of system memory in proportion to the memory limit of ApsaraDB for OceanBase.
For example, if the memory limit of ApsaraDB for OceanBase is 80 GB and the value of the system_memory_percentage parameter is 20%, the system memory is 16 GB (80 GB × 20% = 16 GB). The memory that can be allocated to tenants is 64 GB (80 GB - 16 GB = 64 GB).
The memory that is allocated to tenants includes following two types:
- Non-scalable memory:
- Scalable memory
Non-scalable memory is used by MemStore to store incremental data updates. Scalable memory is managed by KVCache. In most cases, the memory used by KVCache is the remaining memory. The remaining memory is calculated by using the formula: Total memory - Non-scalable memory.
You can use the memstore_limit_percentage parameter to set the maximum percentage of MemStore in proportion to the total memory of the tenant. The write and update operations of the tenant increase the memory usage of MemStore. If the tenant’s MemStore memory reaches the upper limit, subsequent write and update operations are rejected. ApsaraDB for OceanBase determines when to dump or merge to release the memory of MemStore based on the memory usage ratio of MemStore. This ratio is specified by the freeze_trigger_percentage parameter. If the memory consumed by MemStore reaches the upper limit (represented by its percentage to total memory), the memory of MemStore is released, which triggers the dump and merge operations.
In most cases, scalable memory is managed by KVCache. ApsaraDB for OceanBase relies on KVCache to manage the cache in key-value pairs. KVCache supports dynamic scaling, priority control of different key-value pairs, and intelligent elimination mechanisms.
KVCache requires no configurations. In specific scenarios, you can use parameters to specify the priorities of key-value pairs. Key-value pairs with higher priorities are easier to be retained in KVCache than key-value pairs with lower priorities. The following table lists the parameters for your reference.