|
先介绍一下我这边的环境。
windows服务器,16g内存,16核cpu。
平台做了一些修改:
整合redis,原使用spring与redis进行整合,做了session共享,发现经常有jedis连接池 time out的情况,后改成了tomcat与redis整合,用的是tomcat-redis-session-manager1.2.jar\com\orangefunction\tomcat\redissessions - ZIP 压缩文件, 解包大小为 42,701 字节。
这边部署了nginx,一台主,一台备,发布新版本的时候,主备调换防止用户不能使用。
cpu99%的情况大多出现在每次切换服务的时候。
但也有少部分情况,没有做任何操作,半夜的时候cpu就99%。
这次抓到cpu到88%的时候,立即使用nginx进行了切换,才有可操作的余地。
虽然该服务器已经没有任何请求,但cpu仍一直是88%,截至目前为止已持续了1个多小时。
=========================情况介绍完毕====================================
使用jdk自带的visualVM查看了当前正在运行的线程,如下。
正在运行的进程
使用jdk自带的visualVM抓取了dump文件,找到一个状态为RUNNABLE的线程,如下。
问题
注意到图中的 at org.tlmpframework.core.util.ContextHolderUtils.getSession(ContextHolderUtils.java:46) at org.tlmpframework.core.interceptors.AuthInterceptor.preHandle(AuthInterceptor.java:134)
这两条信息,于是去代码里寻找原因,未果。寻求帮助。
可以看到图中的"catalina-exec-56" 在图一中,已经运行了400万毫秒,也就是1小时6分钟。
除了56,还有其他图中绿色的状态为RUNNABLE的线程,信息都是一样的。
56的完整dump信息如下:
"catalina-exec-56" daemon prio=6 tid=0x0000000018905800 nid=0x13ac runnable [0x000000001e5dd000]
java.lang.Thread.State: RUNNABLE
at java.util.HashMap.put(HashMap.java:494)
at org.tlmpframework.core.util.ContextHolderUtils.getSession(ContextHolderUtils.java:46)
at org.tlmpframework.core.interceptors.AuthInterceptor.preHandle(AuthInterceptor.java:134)
at org.springframework.web.servlet.HandlerExecutionChain.applyPreHandle(HandlerExecutionChain.java:134)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:932)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.tlmpframework.filter.ResouceEncodingFilter.doFilter(ResouceEncodingFilter.java:182)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:150)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)
at com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve.invoke(RedisSessionHandlerValve.java:22)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2555)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2544)
- locked <0x00000006864c4630> (a org.apache.tomcat.util.net.AprEndpoint$AprSocketWrapper)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Locked ownable synchronizers:
- <0x000000069c7a5098> (a java.util.concurrent.ThreadPoolExecutor$Worker)
===========================问题描述完毕,可在上班时段远程========================
|
|