jedis - Redis connection pool - spikes in new connections -


i using jedispool connect redis instances in aws elasticache. elasticache helpfully shows metrics regarding connections made cache nodes. have noticed new connections count spikes thousand, despite fact current number of connections stays stable around 20. not find documentation around jedispool understand how connections managed and/or reused.

this how create connection pool:

final jedispoolconfig poolconfig = new jedispoolconfig(); poolconfig.setmaxtotal(128);  this.pgjedis = new jedispool(poolconfig, endpoint, port); 

later, how use it:

try (final jedis jedis = pgjedis.getresource()) {      //use jedis query } catch (exception ex){    throw new runtimeexception("failed while fetching bn pg mappings", ex);         } 

this per documentation at: https://github.com/xetorthio/jedis/wiki/getting-started

since rest based service application, don't destroy pool.

now, not if try/finally block places connection pool or closes it. there way avoid having create many new connections?

my metrics indicate despite fact total number of connections open @ given time remain stable around 20, creating many new connections (which means closing , opening lot). current connections new connections opened


Comments