All Products
Search
Document Center

Memory management

Last Updated: Jan 10, 2020

Set memory limit of ApsaraDB for OceanBase

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.

Configure system memory for ApsaraDB for OceanBase

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).

Configure memory allocated to tenants

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.

Manage 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.

Manage scalable memory

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.

Parameter Default value
clog_cache_priority 1
index_clog_cache_priority 1
user_tab_col_stat_cache_priority 1
index_cache_priority 10
index_info_block_cache_priority 1
user_block_cache_priority 1
user_row_cache_priority 1
bf_cache_priority 1
bf_cache_miss_count_threshold 100