I am using Jedis in a tomcat web application to connect to the Elascticache Redis node. The application is used by hundreds of users in the daytime. I'm not sure if this is normal or not, but whenever I check the current count of connections with cloud indicators, I see that the current connections are growing without falling.
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 so I always use 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); }
In this configuration, the number is currently greater than 200. Did I miss something that was supposed to cancel or kill unused connections? I set maxIdle to 35, and I expected the count to drop to 35 when traffic is very low, but this never happened.
java tomcat amazon-elasticache redis jedis
addonis1990
source share