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.
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.
Valid values of the dynamic-hz parameter are
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
- Log on to the ApsaraDB for Redis console.
- In the upper-left corner of the page, select the region where the instance is deployed.
- On the Instances page, find the target instance, click Instance ID or Manage in the Actions column.
- On the Instance Information page, click System Parameters in the left-side navigation pane.
- On the page that appears, find the dynamic-hz parameter and click Modify in the Actions column.
- In the dialog box that appears, follow these steps to specify the parameter:
- Change the value of the dynamic-hz parameter based on your needs.
- Click OK.
Call API operations to set parameters
You can also call the ModifyInstanceConfig operation to set parameters.