All Products
Search
Document Center

ApsaraDB for Redis:Adjust the frequency of background tasks

Last Updated:Dec 11, 2023

By changing the value of the hz parameter, you can adjust the frequency at which Redis runs background tasks such as evicting expired keys and cleaning up idle connections. This can improve the efficiency of Redis in running such tasks.

Relationship between background tasks and the hz parameter

To periodically check the status of resources and services and perform operations based on specified policies, Redis calls an internal function to run background tasks. The following list provides examples of background tasks:

  • Evict expired keys.

  • Close client connections that have timed out.

  • Update statistics.

The preceding background tasks ensure the normal operation of Redis. The frequency at which these tasks are run is determined by the hz parameter. By default, the hz parameter is set to 10, which indicates that the tasks are run 10 times per second.

Valid values and suggested settings for the hz parameter

The valid values of the hz parameter are 1 to 500. If you increase the value of hz, Redis runs background tasks more frequently. This can increase CPU utilization. In most cases, you can use the default value 10. If you want to run specific background tasks more frequently, specify a value between 10 and 100. We recommend that you do not set the hz parameter to a value greater than 100 to prevent a sharp increase in CPU utilization.

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 hz parameter and click Modify in the Actions column.

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

    1. Change the value of the hz parameter based on your business requirements.

    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.