Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception=redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: Read timed out #2105

Closed
parag90-zz opened this issue Nov 24, 2019 · 3 comments

Comments

@parag90-zz
Copy link

Sometimes I am getting these exceptions on my application connecting to Redis.

I am running a service with 40 containers (spring-boot)
Env: AWS
Redis: AWS managed
Jedis version: 3.1.0
connect.timeout: 700
write.timeout: 1000
maxIdle: 20
minIdle: 20
maxActive: 20
Node type:cache.r4.large
Engine Version: 4.0.10
Java version 1.8
Traffic on the service: 5-7000 Transactions per second.
Issue frequency: Sometimes in 10 days sometimes once a week, No consistency observed. No changes in the incoming traffic pattern at that time.

Observations: New connections at Redis side spikes to 25-30k and the whole system becomes unstable. Huge spike in network packets in during the issue.

Need help in debugging the issue, This causes a live site the service availability going down.

@configuration
@ConfigurationProperties(prefix = "redis")
public class CacheConfiguration {

Map<String, String> hostname = new HashMap<>();

@Value("${redis.port:6379}")
int redisPort;

@Value("${redis.connect.timeout:1000}")
int connectTimeOut;

@Value("${redis.write.timeout:1000}")
int writeTimeOut;

@Value("${redis.enabled:true}")
boolean isRedisEnabled;

@Value("${redis.maxIdle:5}")
int maxIdle;

@Value("${redis.minIdle:1}")
int minIdle;

@Value("${redis.maxActive:10}")
int maxActive;

public Map<String, String> getHostname() {
    return hostname;
}

/**
 * Bean for elasticache.
 *
 * @return configured jedisPool
 */
@Bean
public JedisPool getRedisConfiguration() {
    JedisPool jedisPool = null;
    if (isRedisEnabled) {
        final JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        jedisPoolConfig.setMaxWaitMillis(writeTimeOut);
        jedisPoolConfig.setMaxTotal(maxActive);
        jedisPoolConfig.setMaxIdle(maxIdle);
        jedisPoolConfig.setMinIdle(minIdle);
        final Region region = (Regions.getCurrentRegion() != null) ? Regions.getCurrentRegion() : Region.getRegion(Regions.US_WEST_2);
        jedisPool = new JedisPool(jedisPoolConfig, hostname.get(region.getName()), redisPort, connectTimeOut);
    }
    return jedisPool;
}

}

@parag90-zz
Copy link
Author

Screen Shot 2019-11-24 at 9 26 33 PM

New connection graph when the issue occurs

@Sanshx
Copy link

Sanshx commented Nov 24, 2019

Screenshot 2019-11-24 at 9 33 47 PM

Current connections graphs during the issue. Our app is supposed to maintain 800 connections at total 40 containers.

@mircea-pop
Copy link

We are using a similar stack (jedis 3.0.1, java 11.0.3, spring boot and aws redis 5.0.3)
We also found a similar issue. In our case, we didnt yet pinpoint it to redis/jedis, but it's a top suspect.

Same symptoms: network in spikes, the clients cannot get resources from the jedis pool, the number of new connections on redis go as high as 1.3k (during normal operation it's in 1 digit area)

What we also observed is that the jvm crashes afterwards. Can you check if this is also happening on your side ?

yangbodong22011 added a commit to yangbodong22011/jedis that referenced this issue Apr 3, 2023
Please refer to: redis/redis#11420

This PR cancels calling the quit command when the Jedis internal
link is abnormal, but the user interface `Jedis.quit()` is not
affected. This optimizes Jedis connection pool performance and
fixes: redis#2105
redis#2108
yangbodong22011 added a commit to yangbodong22011/jedis that referenced this issue Apr 4, 2023
Please refer to: redis/redis#11420

This PR cancels calling the quit command when the Jedis internal
link is abnormal, and deprecate the user interface `Jedis.quit()`.
This optimizes Jedis connection pool performance and
fixes: redis#2105
redis#2108
sazzad16 pushed a commit to sazzad16/jedis that referenced this issue Apr 20, 2023
* Jedis avoid using QUIT command

Please refer to: redis/redis#11420

This PR cancels calling the quit command when the Jedis internal
link is abnormal, and deprecate the user interface `Jedis.quit()`.
This optimizes Jedis connection pool performance and
fixes: redis#2105

* Update src/main/java/redis/clients/jedis/Connection.java

Co-authored-by: M Sazzadul Hoque <[email protected]>

* Apply suggestions from code review

Co-authored-by: M Sazzadul Hoque <[email protected]>

---------

Co-authored-by: M Sazzadul Hoque <[email protected]>

---------

 Conflicts:
	src/main/java/redis/clients/jedis/Connection.java
	src/main/java/redis/clients/jedis/ConnectionFactory.java
	src/main/java/redis/clients/jedis/Jedis.java
	src/main/java/redis/clients/jedis/Protocol.java
sazzad16 added a commit that referenced this issue Apr 20, 2023
Backport of #3353 

---------

Please refer to: redis/redis#11420

This PR cancels calling the quit command when the Jedis internal link is abnormal, and deprecate the user interface `Jedis.quit()`. This optimizes Jedis connection pool performance and fixes: #2105

---------

 Conflicts:
	src/main/java/redis/clients/jedis/Connection.java
	src/main/java/redis/clients/jedis/ConnectionFactory.java
	src/main/java/redis/clients/jedis/Jedis.java
	src/main/java/redis/clients/jedis/Protocol.java

* more changes

* Modify makeObject() for Jedis 3.x

---------

Co-authored-by: bodong.ybd <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants