Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The current connections count keeps increasing in my Elasticache Redis node

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.

like image 441
addonis1990 Avatar asked Feb 17 '15 23:02

addonis1990


People also ask

How many connections can ElastiCache handle?

Large number of connections Individual ElastiCache for Redis nodes support up to 65,000 concurrent client connections.

How many concurrent connections Redis can handle?

Maximum Concurrent Connected Clients In Redis 2.6 and newer, this limit is dynamic: by default it is set to 10000 clients, unless otherwise stated by the maxclients directive in redis.

How many Redis connections do I need?

Redis can handle many connections, and by default, Redis has a maximum number of client connections set at 10,000 connections. You can set the maximum number of client connections you want the Redis server to accept by altering the maxclient from within the redis. conf file.

How do I see active connections in Redis?

If you run the "client list" command against your Redis instance, you should be able to see the entire list of clients connected to your redis instance along with their IP addresses. You can then see which clients (services) have the highest number of connections to your Redis instance.


1 Answers

we had the same problem. After investigating a little bit more further we came across with this (from redis official documentation - http://redis.io/topics/clients) :

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

like image 63
Joël Rousseau Avatar answered Nov 15 '22 14:11

Joël Rousseau