我们正在使用 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 池中的连接。可能的修复:
- 正确地将连接返回到池中 (
pool.returnResource()
),如果您没有这样做的话。不要在不需要的时候拿着它们。不要经常断开连接。确保公共(public)池版本至少为1.6
。 增加池大小。
JedisPoolConfig poolConfig = new JedisPoolConfig(); poolConfig.setMaxTotal(...);
增加没有可用连接时的等待时间。
poolConfig.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK); poolConfig.setMaxWait(...);
更新:
有关服务器端限制,请参阅此处:https://stackoverflow.com/a/51539038/78569
关于spring - 如何查找 Redis 中可用的最大连接数以及使用了多少连接数和免费连接数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51363843/