简体   繁体   English

自动化Tomcat线程/堆转储以进行进一步分析

[英]Automating Tomcat Thread/heap dump for further analysis

I am running an web application on tomcat. 我正在tomcat上运行Web应用程序。 Tomcat process is getting hung when there are lots of requests fired. 当有许多请求被触发时,Tomcat进程将被挂起。 Since this is an production web app , i cant monitor all the time to get the tomcat java process/thread dump manually. 由于这是一个生产Web应用程序,因此我无法一直监视手动获取tomcat Java进程/线程转储。

I have already enabled the jmx remote port on tomcat 我已经在tomcat上启用了jmx远程端口

-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=2222 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true

My question is : When the tomcat process hits high CPU[thread count]/Memory usage/got Hung , at that point of time can we collect the tomcat thread dump to desired disk location automatically[command line or programatically] ? 我的问题是:当tomcat进程达到较高的CPU [线程数] /内存使用率/已挂起时,我们可以在那时将该tomcat线程转储自动收集到所需的磁盘位置吗(命令行或以编程方式)?

These options: 这些选项:

JAVA_OPTS='-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/path/to/dir'

will make a core dump when Tomcat runs out of memory. 当Tomcat内存不足时,它将进行核心转储。

Also -verbose:gc option might be useful in this case. 在这种情况下, -verbose:gc选项也可能有用。

B.2.3 -verbose:gc Option B.2.3 -verbose:gc选项

The -verbose:gc option enables logging of garbage collection (GC) information. -verbose:gc选项启用日志记录垃圾收集(GC)信息。 It can be combined with other HotSpot VM specific options such as -XX:+PrintGCDetails and -XX:+PrintGCTimeStamps to get further information about the GC. 可以将其与其他HotSpot VM特定选项结合使用,例如-XX:+PrintGCDetails-XX:+PrintGCTimeStamps以获得有关GC的更多信息。 The information output includes the size of the generations before and after each GC, total size of the heap, the size of objects promoted, and the time taken. 信息输出包括每个GC之前和之后的世代大小,堆的总大小,升级的对象的大小以及花费的时间。

Troubleshooting Guide for HotSpot VM > Command-Line Options HotSpot VM故障排除指南>命令行选项

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM