The dynamic-hz parameter is a new parameter added in Redis 5.0. You can set this parameter to enable or disable dynamic frequency control for background tasks. After dynamic frequency control is enabled, ApsaraDB for Redis can automatically change the frequency of background tasks based on the number of client connections.

Prerequisites

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

Relationship between the hz and dynamic-hz parameters

ApsaraDB for Redis supports various background tasks, such as closing client connections that have timed out and evicting expired keys. The hz parameter specifies the frequency of background tasks in ApsaraDB for Redis. For more information, see Change the frequency of background tasks. However, a fixed frequency may cause the following issues:

  • If the frequency is too low, resources cannot be recycled in a timely manner when a large number of client connections have timed out or a large number of keys have expired. This may lead to poor performance or even crashes of ApsaraDB for Redis.
  • If the frequency is too high, background tasks consume too many CPU resources. The performance of ApsaraDB for Redis may also deteriorate.

To balance the CPU usage and efficiency of background tasks, Redis 5.0 provides the dynamic-hz parameter to enable or disable dynamic frequency control for background tasks. In addition, Redis 5.0 adds the configured_hz parameter to indicate the frequency that you set, and uses the original hz parameter to indicate the actual frequency.

Note You can run the INFO command to query the values of the hz and configured_hz parameters.

Valid values of the dynamic-hz parameter are yes and no. A value of yes enables dynamic frequency control and a value of no disables dynamic frequency control. Default value: yes. After dynamic frequency control is enabled, the value that you specify for the hz parameter is assigned to the configured_hz parameter as the baseline frequency. ApsaraDB for Redis automatically changes the value of the hz parameter based on the number of client connections. The value of the hz parameter increases with the number of client connections. Accordingly, background tasks are performed more frequently.

Specify the parameters in the ApsaraDB for Redis console

  1. Log on to the ApsaraDB for Redis console.
  2. In the upper-left corner of the page, select the region where the instance is deployed.
  3. On the Instances page, find the target instance, click Instance ID or Manage in the Actions column.
  4. On the Instance Information page, click System Parameters in the left-side navigation pane.
  5. On the page that appears, find the dynamic-hz parameter and click Modify in the Actions column.
  6. In the dialog box that appears, follow these steps to specify the parameter:
    1. Change the value of the dynamic-hz parameter based on your needs.
    2. Click OK.

Call API operations to set parameters

You can also call the ModifyInstanceConfig operation to set parameters.