0

We are using REDIS cache , and using Spring-Redis module , we set the maxActiveConnections 10 in application configuration , but sometimes in my applications am seeing below errors

Exception occurred while querying cache : org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

is it because of in the Redis server their are no more connections to give to my applications or any other reason , can anyone please suggest on this ?

Note : their are 15 applications which are using the same Redis server to store the data , i mean 15 applications need connections from this single redis server only , for now we set 10 as maxActiveConnections for each of the 15 applications

Bravo
  • 8,589
  • 14
  • 48
  • 85
  • i’m not sure about application limit but afaik if redis get request more than it can handle (note that this is not application, it is total number of requests) it stores them in a queue, and if the redis queue is full, may be, redis can drop further request until the queue is not full. – aeb-dev Mar 28 '18 at 06:01

1 Answers1

4

To check how many clients are connected to redis you can use redis-cli and type this command: redis> INFO more specifically info Clients command.

192.168.8.176:8023> info Clients
# Clients
connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0

Form Jedis source code, it seems that the exception happened for the following reason:

  1. Exhausted cache: // The exception was caused by an exhausted pool
  2. or // Otherwise, the exception was caused by the implemented activateObject() or ValidateObject()

Here is the code snippet of Jedis getResource method:

  public T getResource() {
    try {
      return internalPool.borrowObject();
    } catch (NoSuchElementException nse) {
      if (null == nse.getCause()) { // The exception was caused by an exhausted pool
        throw new JedisExhaustedPoolException(
            "Could not get a resource since the pool is exhausted", nse);
      }
      // Otherwise, the exception was caused by the implemented activateObject() or ValidateObject()
      throw new JedisException("Could not get a resource from the pool", nse);
    } catch (Exception e) {
      throw new JedisConnectionException("Could not get a resource from the pool", e);
    }
  }
MD Ruhul Amin
  • 4,386
  • 1
  • 22
  • 37