监视java线程执行的工具 [英] Tools to monitor java thread execution

查看:135
本文介绍了监视java线程执行的工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Tomcat服务器(Linux)上运行了一个java Web应用程序。在生产环境中,我遇到了一些性能问题。在随机的时间间隔运行tomcat的jsvc进程开始以90-100%的CPU运行。我无法找到此事件的触发器。服务器是四核系统。内存消耗并不表示有任何异常。

I've a java web application running on an Tomcat server(Linux). In the production environment I'm facing some performance issue. At random intervals the jsvc process on which tomcat is running starts to run at 90-100% CPU. I'm unable to find out the trigger for this event. The server is a quad core system. Memory consumption does not indicate any abnormalities.

如何监控应用程序中的哪个线程(应用程序堆栈跟踪)导致问题?

How can I monitor which thread(application stack trace) in the application is causing the problem?

我正在查看 jconsole 和< a href =http://code.google.com/p/psi-probe/ =nofollow> PSI探测,但两者都没有提供有关应用程序内部线程导致的任何详细信息CPU使用异常。

I'm checking with jconsole and PSI Probe, but both are not giving any detailed information about what thread inside the application is causing the CPU usage abnormality.

推荐答案

执行此操作的一种相对简单的方法(可能适用于您的情况也可能不适用)取决于行为发生的时间):

One relatively easy way to do this (which may or may not work for your case -- depends on how long the behavior occurs):

当您的应用程序展示您要调试的行为(在这种情况下,CPU使用率为90-100%)时,请在流程上使用jstack ID:

When your app exhibits the behavior you want to debug (in this case, 90-100% CPU use) use jstack on the process ID:

http://download.oracle.com/javase/6/docs/technot es / tools / share / jstack.html

检查正在运行的线程及其发生的方式。如果你这样做几次,可能相对容易发现罪魁祸首的调用链。然后,您可以调试该链的入口。

to examine what threads are running and in what methods they occur. If you do that a few times, it may be relatively easy to spot the culprit call chain. You can then just debug the entrance to that chain.

它不一定是最好或最优雅的方法,但它很容易做到,它可能就是你所需要的。我会从那里开始。它类似于printf是我用过的最好的调试器哲学。

It's not necessarily the best or most elegant method, but it's very easy to do and it may be all you need. I would start there. It's akin to the "printf is the best debugger I've ever used" philosophy.

这篇关于监视java线程执行的工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆