spring - 如何查找 Redis 中可用的最大连接数以及使用了多少连接数和免费连接数?

标签 spring spring-boot caching redis jedis

我们正在使用 Spring boot 应用程序中的 Redis,我们像洪水一样低于警报

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

是不是因为他们在 Redis 服务器上没有连接?还是其他原因?

如何找到最大可用连接数?如何找到有多少是免费的?

最佳答案

Could not get a resource from the pool

您已用完客户端 Jedis 池中的连接。可能的修复:

  1. 正确地将连接返回到池中 (pool.returnResource()),如果您没有这样做的话。不要在不需要的时候拿着它们。不要经常断开连接。确保公共(public)池版本至少为 1.6
  2. 增加池大小。

    JedisPoolConfig poolConfig = new JedisPoolConfig();
    poolConfig.setMaxTotal(...);
    
  3. 增加没有可用连接时的等待时间。

    poolConfig.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK);
    poolConfig.setMaxWait(...);
    

更新:

有关服务器端限制,请参阅此处:https://stackoverflow.com/a/51539038/78569

关于spring - 如何查找 Redis 中可用的最大连接数以及使用了多少连接数和免费连接数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51363843/

相关文章:

eclipse - 如何在Eclipse中调试Kotlin Spring Boot App?

PHP APC 缓存,开箱即用吗?

caching - 创建 etag 的最佳方法是什么?

java - 当客户端与热流断开连接时执行一些操作

mysql - JPA/Spring-boot key 'PRIMARY' 的重复条目

java - MongoRepository init 的 Spring Data 异常

java - 为什么@Cacheable内部的条件没有任何影响?

css - 强制刷新缓存的 CSS 数据

java - Spring - 多个@Component

java - 我如何使用 Hibernate/JPA 在插入/更新/删除之前告诉数据库用户是谁?