Database Autonomy Service (DAS) provides the cache analysis feature that helps you analyze backup files of ApsaraDB for Redis instances to provide information about the total memory usage and the memory used by each large key. This feature helps you reduce issues such as insufficient memory and performance degradation that are caused by skewed keys. For a master-replica cluster instance of ApsaraDB for Redis Community Edition, the cache analysis feature can provide statistics about the memory usage on each node.
- The ApsaraDB for Redis instance for which you want to use the cache analysis feature must be connected to DAS and in the Accessed state.
- The cache analysis feature is available only for ApsaraDB for Redis Community Edition instances that run Redis 2.8 or later.
- ApsaraDB for Redis instances that are deployed in the China (Chengdu), UK (London), Germany (Frankfurt), and India (Mumbai) regions do not support the cache analysis feature.
- Log on to the DAS console.
- In the left-side navigation pane, click Instance Monitoring.
- On the Instance Monitoring page, find the database 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 page, click Analyze.
- In the Cache Analysis dialog box, configure the parameters described in the following table.
Parameter Description Node Select the ID of the node on which you want to perform cache analysis. If the database instance is a master-replica cluster instance of ApsaraDB for Redis Community Edition, you can select the ID of the database instance or the ID of a specific node in the instance.Note If you select the ID of a database instance that contains more than eight nodes, DAS 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. You can use the most recent backup file, or create a backup and use the created backup for analysis.
- Click OK.
- On the Cache Analysis page, find the analysis task that is created. After the analysis task is completed,
click Details in the Actions column. On the page that appears, you can view the analysis results.
- Basic Information: In this section, you can view the basic information about the cache analysis, such as the ID of the database instance that is analyzed and the cache analysis method that is used.
- Relevant Nodes: If the database instance is a master-replica cluster instance of ApsaraDB for Redis
Community Edition, you can view the memory usage of each node in the database instance,
such as the total memory usage and the statistics of keys. Note Relevant Nodes information is displayed only if the cache of a master-replica cluster instance of ApsaraDB for Redis Community Edition is analyzed.
- Details: In this section, you can view the total memory usage of the database instance, the statistics that are collected based on keys, such as Daily Growth in the 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), and the top 100 large keys that are ranked based on memory usage, the number of keys, and prefixes.
- Why is the memory usage of keys that are displayed on the Details page less than the
actual memory usage of the keys?
The cache analysis feature calculates the amount of memory that is consumed by keys and their values that are stored in Redis database backup (RDB) files after the keys and the values are serialized. The calculated amount of memory accounts for only part of the used memory space. The used memory also includes the following parts:
- The amount of memory that is consumed by the struct data, pointers that correspond to the keys and values, and byte alignment. After you use jemalloc to allocate the memory of a database instance, data is aligned based on specific rules. If a database instance contains 250 million keys, the total amount of memory that is consumed by the struct data, pointers, and byte alignment can be approximately 2 GB to 3 GB.
- The amount of memory that is consumed by the output buffer, query buffer, and append-only file (AOF) rewrite buffer on your clients, and the amount of memory that is consumed by backlogs. The backlogs are generated during primary/secondary replications.
- What are the delimiters that are used as prefixes to distinguish different types of
data during cache analysis?
:;,_-+@=|#as delimiters to distinguish different types of data during cache analysis.
- Why is the number of elements the same as the length of elements for keys of the String
type in cache analysis for an ApsaraDB for Redis instance?
In cache analysis for an ApsaraDB for Redis instance, the number of elements represents the length of elements for keys of the String type.
- What do I do if the following error occurs?
decode rdbfile error: rdb: unknown object type 116 for key XX
This error indicates that the ApsaraDB for Redis instance has Bloom keys. You can delete these keys from the instance, or upgrade the instance to Enhanced Edition (Tair) and change the Bloom structure to the TairBloom structure.
- Why is the memory usage of Stream keys that are displayed on the Details page several
times greater than the actual memory usage of the keys?
Stream is a complex data structure that uses radix trees and listpacks under the hood. The cache analysis feature cannot accurately identify the memory usage of such complex data structures, which causes deviations in results.Note The exhibited deviations are statistical in nature and do not affect the functionality of the database instance.