DCS Redis Help Documentation

Troubleshooting of Redis Connection Problems

2024-05-25 03:44:15

Overview

This topic describes why Redis connection problems occur and how to solve the problems.

Problem Classification

To troubleshoot abnormal connections to a Redis instance, check the following items:

Connection between the Redis instance and the ECS

Public access

Password

Instance configuration

Client connections

Connection timeout due to performance issues

Connection between the Redis instance and the ECS

The ECS must be located in the same VPC as the Redis instance and be able to communicate with the Redis instance.

Incorrect configurations of security group rules:

Issue Description: The connection is faulty because the security group rules are not configured correctly.

Solution: Correctly configure security group rules for the ECS and the Redis instance to allow the Redis instance to be accessed. For details, see How Do I Configure a Security Group?

A trustlist enabled for an instance:

Issue Description: The instance has a trustlist.

Solution: If the instance has a trustlist, ensure that the client IP address is included in the trustlist. Otherwise, the connection will fail. For details, see Managing IP Address Trustlist. If the client IP address changes, add the new IP address to the trustlist.

Access across VPCs:

Issue Description: Different VPCs cannot communicate with each other. An ECS cannot access a Redis instance if they are in different VPCs.

Solution: You can establish VPC peering connections to allow the ECS to access the Redis instance across VPCs. For more information on how to create and use VPC peering connections, see VPC Peering Connection.

Public access

Before accessing a Redis instance through a public network, ensure that the instance supports public access. For details, see Connecting to a Redis Instance over a Public Network.

Error "Connection reset by peer" is displayed or a message is displayed indicating that the remote host forcibly closes an existing connection.

Possible Reasons: The security group is incorrectly configured.

Solution: Correctly configure the Redis instance and access the instance by following Connecting to a Redis Instance over a Public Network.

The EIP bound to the DCS Redis instance is unbound. As a result, public access is disabled.

Solution: Enable public access for the instance and bind an EIP to the instance on the console. Then, try again.

Password

If the instance password is incorrect, the port can still be accessed but the authentication will fail. If you forget the password, you can reset the password. For details, see Resetting Instance Passwords.

Instance configuration

If a connection to Redis is rejected, log in to the DCS console, go to the instance details page, and modify the maxclients parameter. For details, see Modifying Instance Configuration Parameters.

Client connections

The connection fails when you use redis-cli to connect to a cluster instance.

Solution: Check whether -c is added to the connection command. Ensure that the correct connection command is used when connecting to the cluster nodes.

Run the following command to connect to a cluster instance:

 

./redis-cli -h {dcs_instance_address} -p {port} -a {password} -c



Run the following command to connect to a stand-alone, active/standby, or Proxy cluster instance:

 

./redis-cli -h {dcs_instance_address} -p {port} -a {password}



For details, see  Access Using redis-cli.

Error "Read timed out" or "Could not get a resource from the pool" occurs.

Solution:

Check if the keys command has been used. This command consumes a lot of resources and can easily block Redis. Instead, use the scan command and do not execute the command frequently.

The connection is interrupted.

Solution:

Modify the application timeout duration.

Optimize the service to avoid slow queries.

Replace the keys command with the scan command.

Connection timeout due to performance issues

Connections to an instance may become slow or time out if the CPU usage spikes due to resource-consuming commands such as keys, or too much memory is used because the expiration time is not set for the instance or expired keys remain in the memory. In these cases, do as follows:

Do not use resource-consuming commands.

Use the scan command instead of the keys command to reduce server load and avoid CPU usage spikes.

Setting a proper expiration time:

Too much memory will be used if the expiration time is not set for an instance. Set an appropriate expiration time for data that is no longer needed and clean up expired data regularly.

Setting monitoring metrics and alarms properly:

Set the monitoring metrics and configure alarm rules for timely detection and rectification of performance issues. Monitor metrics such as memory utilization, used memory, and number of active clients to evaluate instance health.

Checking whether the instance has big keys and hot keys:

Big keys and hot keys may deteriorate performance. Perform an analysis on the DCS console to check for big and hot keys, and take corresponding optimization measures. For details, see relevant documents on big and hot keys of Redis instances.

Use proper caching policies:

Use a proper caching policy and choose suitable storage and expiration policies based on your business requirements. This improves caching efficiency and reduces performance pressure.


i.LsbHvSwT3s