You can set the timeout parameter to specify a timeout period for client connections. Then, ApsaraDB for Redis can close client connections that have timed out to recycle resources.


An ApsaraDB for Redis instance of the standard edition is created, and the engine version of the instance is Redis 4.0 and later.

Note You cannot modify the timeout parameter for cluster instances or read/write splitting instances of ApsaraDB for Redis.

Manage client connections in ApsaraDB for Redis

In common scenarios, you can use clients to manage connections. For example, clients can allocate connections, monitor the status of connections, and recycle resources in the connection pool. By default, ApsaraDB for Redis does not close a client connection even if a client has been idle for a long period of time. However, we recommend that you specify the timeout parameter in core applications to allow ApsaraDB for Redis to recycle resources. If resources are not recycled in a timely manner after exceptions occur on clients, the connection pool may be full with idle client connections. This may result in a service crash. Such an issue in core applications may cause serious impact on your business.

The timeout parameter is measured in seconds and the valid values is from 0 to 100000. The default value is 0, which specifies that client connections never time out. To improve performance, ApsaraDB for Redis does not immediately close a client connection when the client connection reaches the timeout period. For example, if the timeout parameter is set to 10 seconds, a client connection may be closed after it is idle for 12 seconds and after many client connections have been created on the shard server. To reduce the latency, you can set a larger value for the hz parameter to increase the frequency of the background task that closes idle connections. For more information, see Change the frequency of background tasks.

Specify the parameter in the ApsaraDB for Redis console

  1. Log on to the ApsaraDB for Redis console.
  2. In the upper-left corner of the page, select the region where the instance is deployed.
  3. On the Instances page, find the target instance, click the instance ID or click Manage in the Actions column.
  4. On the Instance Information page, click System Parameters in the left-side navigation pane.
  5. On the page that appears, find the timeout parameter and click Modify in the Actions column.
  6. In the dialog box that appears, follow these steps to specify the parameter.
    1. Change the value of the timeout parameter based on your requirements.
    2. Click OK.

Call API operations to set parameters

You can also call the ModifyInstanceConfig operation to set parameters.