網(wǎng)站首頁(yè) 編程語(yǔ)言 正文
Spring boot 集成Redis客戶端Lettuce,導(dǎo)致服務(wù)線程數(shù)不斷增加
作者:爆發(fā)的~小宇宙 更新時(shí)間: 2022-05-17 編程語(yǔ)言概述
最近在部署web 項(xiàng)目時(shí)突然發(fā)現(xiàn)項(xiàng)目服務(wù)停止,經(jīng)過排查得知服務(wù)啟動(dòng)后線程數(shù)在不斷增加,從而導(dǎo)致集群資源不夠,服務(wù)停止。
環(huán)境
Spring boot:2.1.6
Redis:4.0.8
jdk:1.8
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-data-redisartifactId>
<version>2.1.5.RELEASEversion>
原因排查
- 服務(wù)啟動(dòng)后觀察查看線程數(shù)
pstree -p pid|wc -l
- 發(fā)現(xiàn)線程數(shù)一直再增加,此時(shí)查看該進(jìn)程的堆棧信息
jstack pid|tee -a /opt/1-3.log
- 堆棧信息
"lettuce-epollEventLoop-4-3" #509 daemon prio=5 os_prio=0 tid=0x00007f2b6c011000 nid=0x1cde runnable [0x00007f2e86aeb000]
java.lang.Thread.State: RUNNABLE
at io.netty.channel.epoll.Native.epollWait0(Native Method)
at io.netty.channel.epoll.Native.epollWait(Native.java:114)
at io.netty.channel.epoll.EpollEventLoop.epollWait(EpollEventLoop.java:256)
at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:281)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:906)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
"lettuce-timer-3-1" #29 prio=5 os_prio=0 tid=0x00007f2e7804e800 nid=0x1cdd waiting on condition [0x00007f2e86ced000]
java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(Native Method)
at io.netty.util.HashedWheelTimer$Worker.waitForNextTick(HashedWheelTimer.java:579)
at io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:478)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
從堆棧信息中我們可以看出出現(xiàn)了很多l(xiāng)ettuce線程,此時(shí)差不多應(yīng)該定位到了應(yīng)該是spring boot集成redis出現(xiàn)的問題了。
當(dāng)時(shí)為了解決問題發(fā)布上線進(jìn)行了如下配置:
#連接池中的最大空閑連接
#spring.redis.lettuce.pool.max-idle=5
#連接池最大連接數(shù)
#spring.redis.lettuce.pool.max-active=8
#連接池中的最小空閑連接
#spring.redis.lettuce.pool.min-idle=1
并且服務(wù)重啟,線程數(shù)不會(huì)增加。
雖然問題解決但是但是但是,坑的地方也在在此。本質(zhì)并沒有找到。。。
后面服務(wù)正常后把配置注釋,線程數(shù)也不會(huì)增加了。說(shuō)明并不是因?yàn)榕渲昧薼ettuce.pool相關(guān)信息解決問題。
目前還沒有還原當(dāng)時(shí)的場(chǎng)景 。
原文鏈接:https://blog.csdn.net/yu0_zhang0/article/details/103863447
相關(guān)推薦
- 2023-01-13 python中的txt文件轉(zhuǎn)換為XML_python
- 2022-06-02 一篇文章帶你了解Python中的裝飾器_python
- 2022-04-08 關(guān)于C++11中限定作用域的枚舉類型的問題_C 語(yǔ)言
- 2022-10-23 Redis的過期鍵刪除策略原理說(shuō)明_Redis
- 2023-08-28 vscode里面報(bào):‘xxx‘ is assigned a value but never used
- 2022-08-05 linux安裝部署lua環(huán)境
- 2022-09-20 android原生實(shí)現(xiàn)多線程斷點(diǎn)續(xù)傳功能_Android
- 2022-11-21 C++?getcwd函數(shù)獲取項(xiàng)目運(yùn)行路徑方法詳解_C 語(yǔ)言
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲(chǔ)小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡(jiǎn)單動(dòng)態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對(duì)象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支