Wildfly 10.1 Consumption All Cores

问题描述:

我们最近将我们的银行应用程序从java 1.6升级到1.8,jboss 4.x升级到wildfly 10.1。Wildfly 10.1 Consumption All Cores

我们观察到,消耗机器上可用的所有内核(10)的Java。

有人可以告诉是什么原因,通常与jboss 4.x最大CPU利用率达4核心。

我需要为垃圾收集配置任何东西吗?

下面是结果(加在过程消耗高CPU)

PS -eLo PID,LWP,NLWP,R用户,PCPU,STIME,ETIME,ARGS | grep的3630

enter image description here

下面是每个LWP消耗高的CPU

enter image description here

现在我已经检查线程转储十六进制对于LWP 7914

“默认任务-7” #182 PRIO = 5 os_prio = 0 TID = 0x00007f5c24033800 NID = 0x1c1a可运行的[0x00007f5bb85e5000] java.lang.Thread.State中: RUNNABLE在 org.xnio .conduits.ConduitStreamSinkChannel.write(ConduitStreamSinkChannel.java:150) 在 io.undertow.channels.DetachableStreamSinkChannel.write(DetachableStreamSinkChannel.java:240) 在 io.undertow.server.HttpServerExchange $ WriteDispatchChannel.write(HttpServerExchange.java :2028) at io.undertow.servlet.spec.ServletOutputStreamImpl.writeBufferBlocking(Ser vletOutputStreamImpl.java:563) 在 io.undertow.servlet.spec.ServletOutputStreamImpl.write(ServletOutputStreamImpl.java:216) 在 java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82) 在java.io. BufferedOutputStream.write(BufferedOutputStream.java:95) - 锁定< 0x00000004d6c5f900>(a java.io.BufferedOutputStream)at com.eko.app.offlineKyc.servlet.KycPictureServlet.doGet(KycPictureServlet.java:58) at javax.servlet .http.HttpServlet.service(HttpServlet.java:687)at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85 ) at io.undertow.servlet.handlers.FilterHandler $ FilterChainImpl.doFilter(FilterHandler.java:129) 在 com.eko.framework.CrossScriptingFilter.doFilter(CrossScriptingFilter.java:48) 在 io.undertow.servlet.core .ManagedFilter.doFilter(ManagedFilter.java:61) 在 io.undertow.servlet.handlers.FilterHandler $ FilterChainImpl.doFilter(FilterHandler.java:131) 在 com.eko.framework.URLSessionFilter.doFilter(URLSessionFilter.java :38) 在 io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) 在 io.undertow.servlet.handlers.FilterHandler $ FilterChainImpl.doFilter(FilterHandler.java:131) at org.mifos.framework.security.util.FileNameFilter.doFilter(FileNameFilter。Java的:59) 在 io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) 在 io.undertow.servlet.handlers.FilterHandler $ FilterChainImpl.doFilter(FilterHandler.java:131) 在 io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) 在 io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) 在 io.undertow.servlet .handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler的.java:78) 在 io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 在 io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) 在 io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) 在 io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 在 io.undertow。 security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:53) at io.undertow.security.handlers.AbstractCo nfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) 在 io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) 在 io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest( ServletSecurityConstraintHandler.java:59) 在 io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) 在 io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest (NotificationReceiverHandler.java:50) 在 io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) 在 io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 在 org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61) 在 io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 在 IO。 undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.h andleFirstRequest(ServletInitialHandler.java:292) 在 io.undertow.servlet.handlers.ServletInitialHandler.access $ 100(ServletInitialHandler.java:81) 在 io.undertow.servlet.handlers.ServletInitialHandler $ 2.call(ServletInitialHandler.java: 138) 在 io.undertow.servlet.handlers.ServletInitialHandler $ 2.call(ServletInitialHandler.java:135) 在 io.undertow.servlet.core.ServletRequestContextThreadSetupAction $ 1.call(ServletRequestContextThreadSetupAction.java:48) 在 IO .undertow.servlet.core.ContextClassLoaderSetupAction $ 1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.api。LegacyThreadSetupActionWrapper $ 1.call(LegacyThreadSetupActionWrapper.java:44) 在 io.undertow.servlet.api.LegacyThreadSetupActionWrapper $ 1.call(LegacyThreadSetupActionWrapper.java:44) 在 io.undertow.servlet.api.LegacyThreadSetupActionWrapper $ 1.call(LegacyThreadSetupActionWrapper的.java:44) 在 io.undertow.servlet.api.LegacyThreadSetupActionWrapper $ 1.call(LegacyThreadSetupActionWrapper.java:44) 在 io.undertow.servlet.api.LegacyThreadSetupActionWrapper $ 1.call(LegacyThreadSetupActionWrapper.java:44) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272) at io.unde rtow.servlet.handlers.ServletInitialHandler.access $ 000(ServletInitialHandler.java:81) 在 io.undertow.servlet.handlers.ServletInitialHandler $ 1.handleRequest(ServletInitialHandler.java:104) 在 io.undertow.server.Connectors。 executeRootHandler(Connectors.java:202) 在 io.undertow.server.HttpServerExchange $ 1.run(HttpServerExchange.java:805) 在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 在 java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

对于LWP 7249

“默认任务-27” #231 PRIO = 5 os_prio = 0 TID = 0x00007f5c2401c000 NID = 0x1c51可运行的[0x00007f5ca9a63000] java.lang.Thread.State中: 在 RUNNABLE有机.xnio.conduits.ConduitStreamSinkChannel.write(ConduitStreamSinkChannel.java:158) 在 io.undertow.channels.DetachableStreamSinkChannel.write(DetachableStreamSinkChannel.java:179) 在 io.undertow.server.HttpServerExchange $ WriteDispatchChannel.write(HttpServerExchange .java:1993) at org.xnio.channels.Channels.writeBlocking(Cha nnels.java:152)在 io.undertow.servlet.spec.ServletOutputStreamImpl.write(ServletOutputStreamImpl.java:283) 在 io.undertow.io.BlockingSenderImpl.writeBuffer(BlockingSenderImpl.java:190) 在io.undertow .io.BlockingSenderImpl.send(BlockingSenderImpl.java:71) 在 io.undertow.server.handlers.resource.CachedResource.serve(CachedResource.java:187) 在 io.undertow.servlet.handlers.DefaultServlet.serveFileBlocking (DefaultServlet.java:332) 在 io.undertow.servlet.handlers.DefaultServlet.doGet(DefaultServlet.java:180) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:687)在 的javax。 servlet.http.HttpServlet.s ervice(HttpServlet.java:790)在 io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) 在 io.undertow.servlet.handlers.FilterHandler $ FilterChainImpl.doFilter(FilterHandler.java:129 ) 在com.eko.framework.MifosNGFilter.doNormal(MifosNGFilter.java:283) 在com.eko.framework.MifosNGFilter.doFilter(MifosNGFilter.java:137) 在 io.undertow.servlet.core.ManagedFilter。的doFilter(ManagedFilter.java:61) 在 io.undertow.servlet.handlers.FilterHandler $ FilterChainImpl.doFilter(FilterHandler.java:131) 在 com.eko.framework.CrossScriptingFilter.doFilter(CrossScriptingFilter。Java的:48) 在 io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) 在 io.undertow.servlet.handlers.FilterHandler $ FilterChainImpl.doFilter(FilterHandler.java:131) 在 com.eko.framework.URLSessionFilter.doFilter(URLSessionFilter.java:38) 在 io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) 在 io.undertow.servlet.handlers.FilterHandler $ FilterChainImpl.doFilter(FilterHandler.java:131) 在 org.mifos.framework.security.util.FileNameFilter.doFilter(FileNameFilter.java:59) 在 io.undertow.servlet.core.ManagedFilte r.doFilter(ManagedFilter.java:61) 在 io.undertow.servlet.handlers.FilterHandler $ FilterChainImpl.doFilter(FilterHandler.java:131) 在 io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler。的java:84) 在 io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) 在 io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) 在 org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78) at io.undertow.server.handlers.Predicat eHandler.handleRequest(PredicateHandler.java:43) 在 io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) 在 io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest( ServletAuthenticationCallHandler.java:57) 在 io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 在 io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:53) 在 io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) 在 io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:59) 在 io.undertow .security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) 在 io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) 在 io.undertow.security.handlers.NotificationReceiverHandler .handleRequest(NotificationReceiverHandler.java:50) at io.under tow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) 在 io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 在 org.wildfly.extension.undertow.security。 jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61) 在 io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 在 io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler。 java:43) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler。Java的:292) 在 io.undertow.servlet.handlers.ServletInitialHandler.access $ 100(ServletInitialHandler.java:81) 在 io.undertow.servlet.handlers.ServletInitialHandler $ 2.call(ServletInitialHandler.java:138) 在 io.undertow.servlet.handlers.ServletInitialHandler $ 2.call(ServletInitialHandler.java:135) 在 io.undertow.servlet.core.ServletRequestContextThreadSetupAction $ 1.call(ServletRequestContextThreadSetupAction.java:48) 在 io.undertow.servlet .core.ContextClassLoaderSetupAction $ 1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.api.LegacyThreadSetupActionWrapper $ 1.call(LegacyThreadSetupActionWrap per.java:44) 在 io.undertow.servlet.api.LegacyThreadSetupActionWrapper $ 1.call(LegacyThreadSetupActionWrapper.java:44) 在 io.undertow.servlet.api.LegacyThreadSetupActionWrapper $ 1.call(LegacyThreadSetupActionWrapper.java:44) 在 io.undertow.servlet.api.LegacyThreadSetupActionWrapper $ 1.call(LegacyThreadSetupActionWrapper.java:44) 在 io.undertow.servlet.api.LegacyThreadSetupActionWrapper $ 1.call(LegacyThreadSetupActionWrapper.java:44) 在 io.undertow .servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272) at io.undertow.servlet.handlers.ServletInitialHandler.access $ 000(ServletIni tialHandler.java:81) 在 io.undertow.servlet.handlers.ServletInitialHandler $ 1.handleRequest(在 io.undertow.server.Connectors.executeRootHandler(Connectors.java:202 ServletInitialHandler.java:104) ) 在 io.undertow.server.HttpServerExchange $在 java.util.concurrent.ThreadPoolExecutor中的$ Worker.run在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)1.run(HttpServerExchange.java:805) (ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

下面是链接,完成线程转储 Thread dump

服务器没有得到稳定,所以我们不得不恢复到JDK 1.6和JBoss 4,我和JBoss的4一切工作完全不知道,现在我无法查明是问题,萤火虫设置,或我的应用程序或GC设置。

线程转储分析链接 Thread dump analysis result

代码KycPictureServlet

@Override 
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 
    ServletOutputStream out = null; 
    FileInputStream fin = null; 
    BufferedInputStream bin = null; 
    BufferedOutputStream bout = null; 
    try { 

     String filename = String.valueOf(request.getParameter("fileName")); 
     String folderPathId = String.valueOf(request.getParameter("folderPathId")); 
     String kycDocPath = ""; 
     System.out.println("Folder Path : " + folderPathId + " \t" + filename); 
     if (folderPathId != null && !folderPathId.equals("null")) { 
      kycDocPath = new StoragePathService().getStoragePathByPathID(Integer.parseInt(folderPathId)).getFolderPath(); 
     } else { 
      kycDocPath = new StoragePathService().getStoragePathByPathID(EkoDBConstants.KYC_FILE_UPLOAD_PATH).getFolderPath(); 
     } 
     String uploadFolderPath = kycDocPath; 
     final String filetofetch = uploadFolderPath + filename; 

     if (filetofetch.toLowerCase().endsWith("pdf")) { 
      response.setContentType("application/pdf"); 
      // response.setHeader("Content-Disposition", "inline; 
      // filename=\"" + filetofetch + "\""); 
     } else if (filetofetch.toLowerCase().endsWith("tif") || filetofetch.endsWith("tiff")) { 
      response.setContentType("image/tiff"); 
     } else { 
      response.setContentType("image/jpeg"); 
     } 

     File uploadFolder = new File(filetofetch); 
     if(uploadFolder != null && uploadFolder.exists()){ 

     out = response.getOutputStream(); 
     fin = new FileInputStream(filetofetch); 
     bin = new BufferedInputStream(fin); 
     bout = new BufferedOutputStream(out); 
     int ch = 0; 
     ; 
     while ((ch = bin.read()) != -1) { 
      bout.write(ch); 

     } 
    } 

    } catch (Exception e) { 
     e.printStackTrace(); 
    } finally { 
     if (bin != null) { 
      bin.close(); 
     } 

     if (fin != null) { 
      fin.close(); 
     } 

     if (bout != null) { 
      bout.close(); 
     } 

     if (out != null) { 
      out.close(); 
     } 

    } 
} 

以前有没有任何finally块,所以异常数据流的情况下没有得到封闭,第二件事情我已经加入额外的检查来检查文件是否存在,然后只打开流。

进行更改后,没有更多线程陷入该servlet中。

我采取了最新的转储,发现了一些奇怪的进程消耗CPU和没有得到最终

"C1 CompilerThread3" #8 daemon prio=9 os_prio=0 tid=0x00007ff8dc231000 nid=0x11b6 waiting on condition [0x0000000000000000] 
    java.lang.Thread.State: RUNNABLE 

"C2 CompilerThread2" #7 daemon prio=9 os_prio=0 tid=0x00007ff8dc22e800 nid=0x11b5 waiting on condition [0x0000000000000000] 
    java.lang.Thread.State: RUNNABLE 

"C2 CompilerThread1" #6 daemon prio=9 os_prio=0 tid=0x00007ff8dc22d000 nid=0x11b4 waiting on condition [0x0000000000000000] 
    java.lang.Thread.State: RUNNABLE 

"C2 CompilerThread0" #5 daemon prio=9 os_prio=0 tid=0x00007ff8dc22a000 nid=0x11b3 waiting on condition [0x0000000000000000] 
    java.lang.Thread.State: RUNNABLE 

旧的Jboss 4

复制在线程转储此外,我已配置气相色谱的设置我已经找到了一些LWP其消耗CPU和未结束

"VM Thread" os_prio=0 tid=0x00007ff8dc1e9000 nid=0x11B411af runnable 

"GC task thread#0 (ParallelGC)" os_prio=0 tid=0x00007ff8dc01e800 nid=0x11a6 runnable 

"GC task thread#1 (ParallelGC)" os_prio=0 tid=0x00007ff8dc020800 nid=0x11a7 runnable 

"GC task thread#2 (ParallelGC)" os_prio=0 tid=0x00007ff8dc022000 nid=0x11a8 runnable 

"GC task thread#3 (ParallelGC)" os_prio=0 tid=0x00007ff8dc024000 nid=0x11a9 runnable 

"GC task thread#4 (ParallelGC)" os_prio=0 tid=0x00007ff8dc026000 nid=0x11aa runnable 

"GC task thread#5 (ParallelGC)" os_prio=0 tid=0x00007ff8dc027800 nid=0x11ab runnable 

"GC task thread#6 (ParallelGC)" os_prio=0 tid=0x00007ff8dc029800 nid=0x11ac runnable 

"GC task thread#7 (ParallelGC)" os_prio=0 tid=0x00007ff8dc02b800 nid=0x11ad runnable 

"GC task thread#8 (ParallelGC)" os_prio=0 tid=0x00007ff8dc02d000 nid=0x11ae runnable 

存储器和GC设定

JAVA_OPTS="-Xms4G -Xmx12G -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=512m -Djava.net.preferIPv4Stack=true -Dsun.rmi.dgc.client.gcInterval=1800000 -Dsun.rmi.dgc.server.gcInterval=1800000 -XX:-UseConcMarkSweepGC -XX:SurvivorRatio=6 -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -Xloggc:/data/eko/GC.log -verbose:gc -XX:NewRatio=2" 
+0

好吧,你的'com.eko.app.offlineKyc.servlet.KycPictureServlet.doGet'做了什么?基于线程转储,考虑到它是一个servlet,它会运行很长时间。你确定,你关闭所有资源(流,servlet响应,..)正确吗?第一个线程是处理某个HTTP请求的servlet处理程序,在IO上明显阻塞,写入时消耗CPU。这个堆栈给出了精确的行号:'58',它被卡住了 - 去检查它。第二个是servlet过滤器,它可能与第一个有关。 – yntelectual

+0

是的你是对的它是一个servlet,如果我们之间有任何异常,我们并没有关闭流,所以我已经添加了finally块来处理这种情况。将部署更改并共享结果。 – ROHIT

+0

@yntelectual现在部署更改后,不会面临该servlet的问题。我再次分析了线程转储,发现了一些奇怪的结果并添加了相同的内容。如果您可以提出有关GC设置的建议,那将非常棒。 – ROHIT

不幸的是,我神奇的水晶球被打破了,所以我们必须让我们的双手变脏。
首先,我们需要弄清楚,什么线程会导致Cpu加载,因为应用程序服务器不是单线程的。 Assumimg你是在Linux上,你可以使用标准的ps让每个进程线程的CPU使用率的详细信息:

ps -eLo pid,lwp,nlwp,ruser,pcpu,stime,etime,args | grep [PID_OF_YOUR_WILDFLY_PROCESS] > unixthread.txt

在这里,我们感兴趣的是列 NLWP LWP和PCPU。找到CPU负载最高的线程。
接下来,我们需要Java线程转储:在高CPU负载期间获取的线程转储:

jstack -l [PID_OF_YOUR_WILDFLY_PROCESS] > jstack.out

现在一些线程狩猎:说你unixthread标识的线程与nwlp 9999的CPU猪,将数字转换为十六进制0x270F并在jstack.out文件中搜索此值。它应该匹配一个java线程和stacktrace,这应该可以帮助你找出问题所在。

如果它与GC相关,那么继续堆转储以确保它不会泄漏到您的应用程序中。
如果你做了你的分析,仍然认为这是jvm或gc设置的问题,你应该联系redhat的人。我相信,如果您打算在RedHat堆栈上运行银行应用程序,那么您应该支付EAP7付费支持,而不是支持Upstream OS项目,而不支持最终的错误或问题。

+0

添加结果ps -eLo pid,lwp,nlwp,ruser,pcpu,stime,etime,args | grep – ROHIT

+0

我已经更新了ps命令。基本上你只需要pid,lwp和pcpu - 'ps -eLo pid,lwp,pcpu | grep '。输出将有三列:process pid,lwp(thread id),pcpu(cpu load)像这样:'4192 4192 0.0'' '4192 4193 0.0' '4192 4194 0.0' 所以你的lwp是第二列,转换为十六进制后,您应该在线程转储中找到匹配项。 – yntelectual

+0

感谢您的帮助,我已经发现了一些消耗CPU的线程。 – ROHIT