Bravo
Bravo

Reputation: 9029

How to check how many total redis connection , that a REDIS server can given to clients?

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

Upvotes: 0

Views: 11893

Answers (1)

MD Ruhul Amin
MD Ruhul Amin

Reputation: 4492

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);
    }
  }

Upvotes: 4

Related Questions