cpu使用率100%问题
案例1:测试环境一个springboot服务部署在阿里云serverless,后台监控显示cpu占比100%,日志里未发现代码报错,此时该服务提供的接口均不能访问
//top -H -p pid 查看线程信息:cpu占有率高的两个线程
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
21 root 20 0 3085284 544152 20840 R 49.5 13.5 27:13.11 Wisp-Root-W+
22 root 20 0 3085284 544152 20840 R 49.5 13.5 27:13.42 Wisp-Root-W+
//jstack pid|grep -A 10 spid 查看堆栈信息
- Coroutine [0x7f4bb4051e80] "Pinpoint-SocketFactory-Timer(13-0)" #15 active=200 steal=0 steal_fail=0 preempt=0 park=1/-1 containerId=0 cg=0/0 ttr=0
at java.dyn.CoroutineSupport.unsafeSymmetricYieldTo(CoroutineSupport.java:140)
at com.alibaba.wisp.engine.WispTask.switchTo(WispTask.java:325)
at com.alibaba.wisp.engine.WispCarrier.yieldTo(WispCarrier.java:435)
at com.alibaba.wisp.engine.WispCarrier.schedule(WispCarrier.java:273)
at com.alibaba.wisp.engine.WispTask.parkInternal(WispTask.java:417)
at com.alibaba.wisp.engine.WispTask.jdkPark(WispTask.java:469)
at com.alibaba.wisp.engine.WispTask.sleep(WispTask.java:353)
at com.alibaba.wisp.engine.WispEngine$5.sleep(WispEngine.java:246)
at java.lang.Thread.sleep(Thread.java:384)
at org.jboss.netty.util.HashedWheelTimer$Worker.waitForNextTick(HashedWheelTimer.java:445)
--
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:153)
- Coroutine [0x7f4bc0007ef0] "Timer-0" #9 active=5 steal=0 steal_fail=0 preempt=0 park=-1/0 containerId=0 cg=0/0 ttr=0
at java.dyn.CoroutineSupport.unsafeSymmetricYieldTo(CoroutineSupport.java:140)
at com.alibaba.wisp.engine.WispTask.switchTo(WispTask.java:325)
at com.alibaba.wisp.engine.WispCarrier.yieldTo(WispCarrier.java:435)
at com.alibaba.wisp.engine.WispCarrier.schedule(WispCarrier.java:273)
at com.alibaba.wisp.engine.WispTask.parkInternal(WispTask.java:417)
at com.alibaba.wisp.engine.WispTask.park(WispTask.java:480)
at java.lang.Object.wait(Native Method)
at java.util.TimerThread.mainLoop(Timer.java:552)
- waiting to lock <0x00000000e037e3b8> (a java.util.TaskQueue)
at java.util.TimerThread.run(Timer.java:505)
at com.alibaba.wisp.engine.WispTask.runOutsideWisp(WispTask.java:295)
at com.alibaba.wisp.engine.WispTask.runCommand(WispTask.java:270)
at com.alibaba.wisp.engine.WispTask.access$100(WispTask.java:53)
at com.alibaba.wisp.engine.WispTask$CacheableCoroutine.run(WispTask.java:241)
at java.dyn.CoroutineBase.startInternal(CoroutineBase.java:62)
//java -version 查看jdk版本
openjdk version "1.8.0_302"
OpenJDK Runtime Environment (Alibaba Dragonwell 8.8.8-b01) (build 1.8.0_302-b1)
OpenJDK 64-Bit Server VM (Alibaba Dragonwell 8.8.8-b01) (build 25.302-b1, mixed mode)
解决办法:测试环境使用了 OpenJDK Dragonwell版本,线程信息和堆栈信息均有wisp提示,可能和jdk版本有关系,切换到 OpenJDK 版本后,cpu使用率下来了,服务正常。具体 Dragonwell 版本哪里引起的问题,不知道了,待以后查看
正文到此结束
- 本文标签: java
- 本文链接: https://codeis.run/article/java-cpu-100
- 版权声明: 本文由醒醒原创发布,转载请遵循《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权