Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 694 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The current connections count keeps increasing in my Elasticache Redis node

#1
I am using Jedis in a tomcat web app to connect to an Elascticache Redis node. The app is used by hundreds of users in day time. I am not sure of this is normal or not, but whenever I check the current connections count with cloudwatch metrics, I see the current connections increasing without falling down.

This is my Jedis pool configuration:

public static JedisPool getPool(){
if(pool == null){
JedisPoolConfig config = new JedisPoolConfig();
config.setMinIdle(5);
config.setMaxIdle(35);
config.setMaxTotal(1500);
config.setMaxWaitMillis(3000);
config.setTestOnBorrow(true);
config.setTestWhileIdle(true);
pool = new JedisPool(config, PropertiesManager.getInstance().getRedisServer());
}
return pool;
}


and this is how I always use the pool connections to execute redis commands:

Jedis jedis = JedisUtil.getPool().getResource();
try{
//Redis commands
}
catch(JedisException e){
e.printStackTrace();
throw e;
}finally{
if (jedis != null) JedisUtil.getPool().returnResource(jedis);
}

With this configuration, the count is currently over 200. Am I missing something that is supposed to discard or kill unsused connections ? I set maxIdle to 35 and I expected that the count falls down to 35 when the traffic is very low but this never happened.
Reply

#2
we had the same problem. After investigating a little bit more further we came across with this (from redis official documentation -

[To see links please register here]

) :

> By default recent versions of Redis don't close the connection with the client if the client is idle for many seconds: the connection will remain open forever.

By default, aws provides a timeout value of 0. Therefore, any connection that has been initialised with your redis instance will be kept by redis even if the connection initialised by your client is down.

Create a new cache parameter policy in aws with a timeout different of 0 and then you should be good
Reply

#3
You can check the pool size using JMX. Activating the idle evictor thread is a good idea. You can do so by setting the `timeBetweenEvictionRunsMillis` parameter on the `JedisPoolConfig`.

If you don't use transactions (`EXEC`) or blocking operations (`BLPOP`, `BRPOP`), you could stick to one connection if connection count is a concern for you. The [lettuce client](

[To see links please register here]

) is thread-safe with one connection
Reply

#4
In the cache parameter group you can edit `timeout`. It defaults to 0 which leaves idle connection in redis. If you set it to 100 it will remove connections idle for 100 seconds.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through