All Products
Search
Document Center

Tair (Redis® OSS-Compatible):Specify a timeout period for idle client connections

Last Updated:Nov 14, 2024

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

  1. 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.

  2. In the left-side navigation pane, click Parameter Settings.

  3. In the parameter list, 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.

    Valid values: 0 to 100000. Unit: seconds.

  5. Click OK.

    The configuration takes effect immediately.

Related API operations

API operation

Description

DescribeParameters

Queries the configuration and operational parameters of an instance.

ModifyInstanceConfig

Modifies the parameter settings of an instance.