All Products
Search
Document Center

Database Autonomy Service:Cache analysis

Last Updated:Aug 20, 2024

Database Autonomy Service (DAS) provides the cache analysis feature that helps you analyze the backup files of ApsaraDB for Redis instances. This way, you can identify large keys in the instances, obtain information such as the memory usage, distribution, and expiration time of keys, and then optimize your instances based on the analysis results. This feature helps you resolve issues such as insufficient memory and performance degradation that are caused by the skewed distribution of keys.

Feature description

The cache analysis feature is supported based on the Redis database (RDB) persistence policy and is available to ApsaraDB for Redis 7.0 instances.

Limits

  • The ApsaraDB for Redis instance for which you want to use the cache analysis feature must be connected to DAS and in the Normal Access state.

  • The cache analysis feature is unavailable to ApsaraDB for Redis Enhanced Edition (Tair) instances that use Enterprise SSDs (ESSDs) and SSDs.

  • The cache analysis feature is supported only for Redis data structures and the following self-developed Tair data structures: TairString, TairHash, TairGIS, TairBloom, TairDoc, TairCpc, and TairZset. Other self-developed Tair data structures do not support the cache analysis feature.

  • If the specifications of an ApsaraDB for Redis instance are changed, you cannot analyze the backup files that are generated before the change.

Procedure

  1. Log on to the DAS console.

  2. In the left-side navigation pane, click Instance Monitoring.

  3. On the page that appears, find the database instance that you want to manage and click the instance ID. The instance details page appears.

  4. In the left-side navigation pane, choose Request Analysis > Cache Analysis.

  5. In the upper-right corner of the Cache Analysis page, click Analyze.

  6. In the Cache Analysis dialog box, configure the parameters that are described in the following table.

    zs

    Parameter

    Description

    Node

    The ID of the node on which you want to perform cache analysis.

    Note

    You can select an instance or a node for analysis.

    Analysis Method

    The mode in which you select the backup files for analysis. Valid values:

    • Use Recent Backup File: analyzes the most recent backup file.

    • Create New Backup for Analysis: backs up an ApsaraDB for Redis instance immediately and analyzes the new backup file. This allows you to analyze the current status of the instance.

    • Select a historical backup file: analyzes a historical backup file.

    Note

    If you analyze an existing backup file, make sure that the point in time when the backup file is generated meets your requirements.

    Delimiter

    The delimiters used to identify prefixes of keys. If you use the following default delimiters, you do not need to specify the delimiters: :;,_-+@=|#.

  7. Click OK.

  8. On the Cache Analysis page, find the analysis task that is created. After the analysis task is complete, 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 Avg Daily Increase in Last Week, 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.

FAQ

  • Why is the amount of memory usage of keys that are displayed on the Details page smaller 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?

    DAS uses :;,_-+@=|# as delimiters to distinguish 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 decode rdbfile error: rdb: unknown object type 116 for key XX error message appears?

    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.

  • What do I do if the decode rdbfile error: rdb: invalid file format error message appears?

    This error indicates that the selected backup file is invalid. Check whether the specifications of the ApsaraDB for Redis instance are changed after the backup file is created. Alternatively, check whether transparent data encryption (TDE) is enabled for the ApsaraDB for Redis instance. The offline key analysis feature cannot analyze encrypted information.

  • What do I do if the decode rdbfile error: rdb: unknown module type error message appears?

    This error indicates the backup file contains self-developed Tair data structures and cannot be analyzed.

  • When I create a cache analysis task for an instance, I set the Analysis Method parameter to Create New Backup for Analysis. What do I do if the XXX backup failed error occurs?

    A BGSAVE or BGREWRITEAOF command is being run on the instance. Therefore, the backup file that is used for the cache analysis task cannot be created. We recommend that you create backup files during off-peak hours, and use the latest backup file or historical backup files to create a cache analysis task.

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

References

You can also use the cache analysis feature in the ApsaraDB for Redis console. For more information, see Use the offline key analysis feature.

Related API operations

Operation

Description

CreateCacheAnalysisJob

Creates a cache analysis task.

DescribeCacheAnalysisJob

Queries the details of a cache analysis task.

DescribeCacheAnalysisJobs

Queries the cache analysis tasks.