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.
Scenarios
Tair runs background tasks to delete expired keys. The following section describes this process:
- Tair randomly selects 20 keys whose time to live (TTL) is specified and checks whether these keys are expired.
- Tair identifies expired keys and deletes them.
- 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
Procedure
Related API operations
Operation | Description |
---|---|
DescribeParameters | Queries the configuration and operational parameters of a Tair instance. |
ModifyInstanceConfig | Modifies parameters of a Tair instance. |