The timeout parameter in Tair (Redis OSS-compatible) is used to specify a timeout period for idle client connections to the Redis server. If a client connection remains idle for the duration specified by the timeout parameter, Tair (Redis OSS-compatible) automatically closes the connection to conserve connection resources.
Timeout mechanism for idle connections
In common scenarios, you can use clients to manage connections. For example, you can use clients to allocate connections, monitor the status of connections, and recycle resources in the connection pool.
The default value of the timeout parameter is 0, which indicates that Tair or Redis Open-Source Edition does not disconnect from an idle client even if the client has been idle for an extended period of time. If resources cannot be recycled in a timely manner after exceptions occur on clients, the connection pool may be filled with idle client connections. This may result in a service failure. Such an issue in core applications may cause severe impacts on your business. Therefore, we recommend that you configure the timeout parameter in core business applications to allow Tair (Redis OSS-compatible) to proactively recycle connection resources.
When a client connection reaches the timeout value, Tair (Redis OSS-compatible) may not immediately close the connection. Tair (Redis OSS-compatible) performs background tasks to periodically check for and close idle connections. If hz is set to a low value, the background tasks are executed less frequently. As a consequence, an idle connection may not be closed immediately after it reaches the specified timeout value. For example, if you set the timeout parameter to 10 seconds, a client connection may remain idle for 12 seconds before it is closed. To reduce latency, you can specify a larger value for the hz parameter to increase the execution frequency of background tasks such as closing idle connections.
Procedure
Log on to the 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.
In the left-side navigation pane, click Parameter Settings.
In the parameter list, find the timeout parameter and click Modify in the Actions column.
In the dialog box that appears, change the value of the timeout parameter.
Valid values: 0 to 100000. Unit: seconds.
Click OK.
The configuration takes effect immediately.
Related API operations
API operation | Description |
Queries the configuration and operational parameters of an instance. | |
Modifies the parameter settings of an instance. |