Database Autonomy Service (DAS) provides the cache analysis feature. You can use this feature to analyze the backup files of ApsaraDB for Redis instances to check the memory usage and the distribution of big keys. This can reduce issues, such as out of memory and performance degradation, that are caused by inappropriate distribution of keys. For an ApsaraDB for Redis Community Edition cluster instance, the cache analysis feature can also provide statistics about the memory usage on each node.
- Your ApsaraDB for Redis instance must be connected to DAS and in the Accessed state. For more information, see Access an Alibaba Cloud database instance and Connect to self-managed databases.
- For ApsaraDB for Redis, the cache analysis feature is available only for Community Edition cluster instances whose engine versions are 2.8 or later.
- ApsaraDB for Redis instances cannot be created in the following regions: China (Chengdu), UK (London), Germany (Frankfurt), and India (Mumbai).
- Log on to the DAS console.
- In the left-side navigation pane, click Instance Monitoring.
- On the Instance Monitoring page, find the instance on which you want to perform cache analysis and click the instance ID. The instance details page appears.
- In the left-side navigation pane, choose Request Analysis > Cache Analysis.
- In the upper-right corner of the Cache Analysis tab, click Analyze.
- In the Cache Analysis dialog box, configure the parameters described in the following table.
Parameter Description Select an analysis node Select the ID of the node on which you want to perform cache analysis. For an ApsaraDB for Redis Community Edition cluster instance, you can select the instance or a specific node of the instance for analysis.Note If you select an instance that has more than eight nodes, the system analyzes only the eight nodes that have the highest memory usage. Analysis Method Select the method that you want to use to analyze the cache. Valid values: Use the previous backup file and Create a backup and use the latest backup for analysis.
- Click OK.
- In the Cache Analysis list, find the analysis task. After the state of the task changes to Completed, click
Details in the Actions column. You can view the following analysis results:
- Basic Information: displays the basic instance information, such as the basic attributes and the cache analysis method.
- Relevant Nodes: displays the memory usage and the key statistics about each node of the ApsaraDB
for Redis Community Edition cluster instance.
Note The memory usage and the key statistics are displayed only if you select an ApsaraDB for Redis Community Edition cluster instance to perform the cache analysis.
- Details: displays the memory usage of the instance, the memory usage of keys, and the top 100 big keys filtered by memory usage, quantity, or key prefix. The following statistics about the memory usage of keys are provided: Daily Growth in Last 7 Days, Total Number of Keys, Memory Usage of Keys, Distribution of Keys, Memory Usage of Elements, Distribution of Elements, Distribution of Key Expiration Time (Memory), and Distribution of Key Expiration Time (Quantity).
- Why is the size of the memory consumed by keys in the cache analysis result smaller than that of the actual memory consumed by the
The cache analysis feature calculates only the size of the memory consumed by keys and their values after the keys and values are serialized and stored in Redis Database Backup (RDB) files. The calculated size accounts for only a portion of the used memory space specified by used_memory. Other portions that are not analyzed are included in the memory space specified by used_memory:
- The size of the memory consumed by the struct and the pointer that correspond to these keys and values. After the memory is allocated in jemalloc, the size of the memory consumed by byte alignment is also not included in the used memory specified by used_memory. For example, the total size of the memory consumed by the struct, the pointer, and byte alignment of 0.25 billion keys can be approximately 2 to 3 GB. However, 2 to 3 GB memory is not included in the used memory space specified by used_memory.
- The output buffer, query buffer, and append-only file (AOF) rewrite buffer in clients, and the backlogs generated during primary/secondary replication are also not calculated in the cache analysis result.
- What is the prefix delimiter used in the ApsaraDB for Redis cache analysis feature?
The prefix delimiter is a fixed string: