某产品每次重启Tomcat都会收到CPU告警信息,重启阶段CPU使用率可以达到80%~90%以上,会持续一段时间回降(具体时间没有考察)。应产品方要求,对该问题进行分析定位。
因线上产品不能随便重启,问题定位阶段使用的是同规格的云主机QA19,该环境上有和线上一致的应用程序,且重启tomcat时,也会有CPU飙高的现象。
负载高的原因:
重启的时候对资源使用情况进行监控,并通过top-H+jstack分析消耗CPU过高的线程堆栈信息。
通过监控重启时的资源使用情况,在qa19这台机器上,重启一次,CPU飙高的持续时间约为50-60s左右。
通过top-H+jstack定位消耗CPU过高的线程,发现有三个:
1.springapplicationContext在web容器中加载过程消耗的资源:(部分堆栈信息)
"main" prio=10 tid=0x000000004166f800 nid=0x100f runnable [0x00007fbf42987000] java.lang.Thread.State: RUNNABLE at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:384) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) |
2.两个编译线程:
"C2CompilerThread1"daemonprio=10tid=0x00007fec48001800nid=0x13c4runnable java.lang.Thread.State:RUNNABLE "C2CompilerThread0"daemonprio=10tid=0x00000000407c1000nid=0x13c3runnable java.lang.Thread.State:RUNNABLE |