Java应用程序中的高CPU利用率 - 为什么? [英] High CPU Utilization in java application - why?

查看:233
本文介绍了Java应用程序中的高CPU利用率 - 为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Java应用程序(基于Web),有时会显示非常高的CPU利用率(几乎90%)几个小时。 Linux TOP 命令显示了这一点。在重新启动应用程序时,问题就会消失。

I have a Java Application (web-based) that at times shows very high CPU Utilization (almost 90%) for several hours. Linux TOP command shows this. On application restart, the problem goes away.

所以要调查

So to investigate:

我使用Thread Dump来查找正在执行的线程。在'RUNNABLE'状态中可以找到多个线程,其中一些在其他几个状态中。在重复的线程转储中,我确实看到一些线程始终存在于'RUNNABLE'状态。所以,他们似乎是罪魁祸首。

I take Thread Dump to find what threads are doing. Several Threads are found in 'RUNNABLE' state, some in few other states. On taking repeated Thread Dumps, i do see some threads that are always present in 'RUNNABLE' state. So, they appear to be the culprit.

但我无法确定,哪个Thread正在占用CPU或进入无限循环(从而导致高CPU util)。

But I am unable to tell for sure, which Thread is hogging the CPU or has gone into a infinite loop (thereby causing high CPU util).

日志不一定有用,因为有问题的代码可能没有记录任何内容。

Logs don't necessarily help, as the offending code may not be logging anything.

我如何调查 - 应用程序的哪个部分或什么线程导致高CPU利用率? - 任何其他想法?

How do I investigate - What part of the application or what-thread is causing High CPU Utilization? - Any other ideas?

推荐答案

如果您的设置中不适用于探查器,您可以尝试在这篇文章

If a profiler is not applicable in your setup, you may try to identify the thread following steps in this post.

基本上,有三个步骤:


  1. 运行 top -H 并获取具有最高CPU的线程的PID。

  2. 将PID转换为十六进制。

  3. 在你的线程转储中寻找具有匹配HEX PID的线程。

  1. run top -H and get PID of the thread with highest CPU.
  2. convert the PID to hex.
  3. look for thread with the matching HEX PID in your thread dump.

这篇关于Java应用程序中的高CPU利用率 - 为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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