All Products
Search
Document Center

ApsaraDB for Redis:Enable dynamic frequency control for background tasks

Last Updated:Dec 07, 2023

After the dynamic-hz feature is enabled for an ApsaraDB for Redis instance, the instance automatically adjusts the hz value (frequency of background tasks) based on the current number of connections. This feature helps to prevent instances becoming unresponsive or experiencing latency due to an excessive number of connections being scanned during background tasks.

Background information

The hz parameter specifies the frequency at which Redis runs background tasks. The tasks include closing client connections that have timed out and evicting expired keys. For more information, see Adjust the frequency of background tasks.

During the processing of client connections, each background task scans a specific number of connections, which is determined by the clients/hz value. The number of connections that are scanned by a task increases with the number of connections to an instance. If an excessive number of connections are scanned by a task, the instance may slow down and become unstable.

To address this issue, ApsaraDB for Redis Community Edition 5.0 has introduced the dynamic-hz feature. This feature allows an instance to automatically adjust the hz value based on the current number of connections to the instance. This prevents the instance from becoming overwhelmed when an excessive number of connections (clients/hz) are scanned in a single task.

The valid values of the dynamic-hz parameter are yes and no. The default value is yes. After you enable the dynamic-hz feature, the value that you specify for the hz parameter is assigned to the configured_hz parameter as the baseline frequency. Redis adjusts the hz value based on the number of client connections to the Redis instance. The hz value increases with the number of client connections. In this case, Redis runs background tasks more frequently.

You can run the INFO command to obtain the baseline value and the actual hz value after dynamic adjustment.

Prerequisites

The engine version of the ApsaraDB for Redis instance is Redis 5.0 or later.

Procedure

  1. Log on to the ApsaraDB for Redis console and go to the Instances page. In the top navigation bar, select the region in which the instance that you want to manage resides. Then, find the instance and click the instance ID.

  2. In the left-side navigation pane, click System Parameters.

  3. On the page that appears, find the dynamic-hz parameter and click Modify in the Actions column.

  4. In the dialog box that appears, perform the following steps:

    1. Configure the dynamic-hz parameter.

    2. Click OK.

Related API operations

Operation

Description

DescribeParameters

Queries the configuration and operational parameters of an ApsaraDB for Redis instance.

ModifyInstanceConfig

Modifies the configuration parameters of an ApsaraDB for Redis instance.