spring - 如何找到 Redis 中可用的最大连接数以及使用的连接数和免费的连接数?
问题描述
我们正在使用 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 服务器中没有连接吗?或任何其他原因?
如何找到最大可用连接数?如何找到有多少是免费的?
解决方案
无法从池中获取资源
您在客户端的 Jedis 池中的连接已用完。可能的修复:
pool.returnResource()
如果您不这样做,请正确返回到池的连接 ( )。不要在不需要它们时握住它们。不要定期断开连接。确保 commons-pool 版本至少为1.6
.增加池大小。
JedisPoolConfig poolConfig = new JedisPoolConfig(); poolConfig.setMaxTotal(...);
增加没有可用连接时的等待时间。
poolConfig.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK); poolConfig.setMaxWait(...);
更新:
有关服务器端限制,请参见此处:https ://stackoverflow.com/a/51539038/78569
推荐阅读
- ios - 在 xcode 中打开 react native 项目
- javascript - 获取最后 5 个数据属性并检查它们是否相同
- gulp - gulp-markdown-docs yaml 解析错误
- python - Python/Pandas:重命名 DataFrame 列中的元素
- sql - 减少客户的总和
- ios - 如何按月份对获取的日期进行分组
- authentication - 为什么要从 token 中减去前 7 个字符
- android - 添加 FlutterToast 时生成错误
- regex - 正则表达式匹配 URL 的相对路径
- ruby-on-rails - 为 Rails 应用程序生成动态计划