You can modify the hz parameter to change the frequency at which Tair runs background tasks to delete expired keys and close client connections that have timed out.

Relationship between Tair background tasks and the hz parameter

To periodically check the status of resources and services and take actions based on specified policies, Tair calls an internal function to run background tasks. The following section lists specific background tasks:

  • Calculate the least recently used (LRU) information and delete expired keys.
  • Close client connections that have timed out.
  • Manage hashes.
  • Perform Redis Database (RDB) or Append Only File (AOF) persistence operations.
  • Update statistics.

Tair runs background tasks to ensure service availability. Tair uses the hz parameter to control the frequency at which background tasks are executed. The default value of this parameter is 10, which indicates that Tair runs background tasks 10 times per second.


Tair runs background tasks to delete expired keys. The following section describes this process:

  1. Tair randomly selects 20 keys whose time to live (TTL) is specified and checks whether these keys are expired.
  2. Tair identifies expired keys and deletes them.
  3. If more than 25% of the selected keys are expired, Tair runs the background task again.

If a large number of expired keys exist or a sharp increase in expired keys occurs and Tair does not delete these keys frequently enough, the remaining expired keys occupy a large amount of memory and may affect the performance of Tair. To resolve this issue, you can increase the value of the hz parameter to allow background tasks to be executed more frequently.

Valid values and suggested settings for the hz parameter

Valid values of the hz parameter are 1 to 500. If you increase the value of the hz parameter, background tasks are executed more frequently but the CPU utilization of Tair also increases. You can use the default value 10 in most cases. If you want to run specific background tasks more frequently, set a value between 10 and 100.
Warning We recommend that you do not set the hz parameter to a value greater than 100, because this may cause a sharp increase in CPU utilization.


  1. Log on to the Tair console and go to the Instances page. In the top navigation bar, select the region in which the instance that you want to manage is deployed. Then, find the instance and click its 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 a Tair instance.
ModifyInstanceConfig Modifies parameters of a Tair instance.