All Products
Search
Document Center

Tair:Set a timeout period for idle client connections

Last Updated:Apr 03, 2024

The timeout parameter in Tair is used to set 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 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. By default, Redis does not proactively close idle connections, even if a 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 crash. Such an issue in core applications may cause serious impacts on your business. Therefore, we recommend that you configure the timeout parameter in core business applications to allow Tair to proactively recycle connection resources.

The valid values of the timeout parameter are 0 to 100000. The default value is 0, which indicates that idle connections are not closed. Unit: seconds. To improve performance, Tair does not immediately close a client connection when the client connection reaches the timeout value. Tair performs background tasks to periodically check for and close idle connections. If hz is set to a low value, Redis checks for idle connections 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 frequency of background tasks that close idle connections.

Procedure

  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 resides. Then, find the instance and click the instance ID.

  2. In the left-side navigation pane, click System Parameters.

  3. On the System Parameters page, find the timeout parameter and click Modify in the Actions column.

  4. In the dialog box that appears, change the value of the timeout parameter.

  5. Click OK.

Related operations

Operation

Description

DescribeParameters

Queries the configuration and operational parameters of a Tair instance.

ModifyInstanceConfig

Modifies the values of parameters of a Tair instance.