压测环境
- springboot版本为1.5.19,使用的spring data redis,其中jedis版本为2.9.1
- 压测工具使用jmeter,200个并发线程持续5分钟
现象
-
测试反映jemeter报大量的http超时
-
查看日志发现请求的响应时间随着时间的推移逐渐增大,应用重启之后报异常
redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
问题排查
-
首先根据异常栈,定位到报错的jedis连接池的源码,梳理了一下获取连接的流程,代码如下:
// 获取连接 public T getResource() { try { return internalPool.borrowObject(); } catch (NoSuchElementException nse) { 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); } } // 从连接池中取一个连接 public T borrowObject() throws Exception { return borrowObject(getMaxWaitMillis

本文记录了一次压测中遇到的jedis连接池泄露问题,详细描述了从现象到排查过程,包括查看日志、分析线程堆栈、调整配置、检查代码依赖和优化连接池。最终,通过升级jedis版本解决了问题,总结了问题排查的经验和方法。
最低0.47元/天 解锁文章
2万+

被折叠的 条评论
为什么被折叠?



