Help Center/ Distributed Cache Service/ FAQs/ Redis Usage/ Why Do I Need to Configure Timeout for Redis Cluster?
Updated on 2023-06-16 GMT+08:00

Why Do I Need to Configure Timeout for Redis Cluster?

If timeout is not configured, connections will fail.

When you connect to a Redis Cluster instance using Spring Boot and Lettuce, connect to all cluster nodes, including faulty replicas.

  • If timeout is not configured, minute-level blocking (120s in earlier Lettuce versions and 60s in the new version) may occur when there is a faulty replica, as shown in the following figure.

    The end-to-end service access time may reach the maximum timeout, as shown in the following figure.

  • After the timeout parameter is configured on the client, the timeout on the replica will be greatly shortened. You can adjust the timeout based on the service requirements. Assume that the configuration is as follows.

    The following figure shows the end-to-end service access time after the configuration is complete.

If the timeout parameter is not configured and there is a faulty node, client connections will be blocked.

Configure the timeout based on what the service can tolerate. For example, if you need to request Redis twice in an HTTP request and the maximum timeout of an HTTP request is 10s, it is recommended that you set the timeout in Redis to 5s. This prevents service interruption if faults occur due to a long timeout duration or no timeout duration.