应用程序服务器过度使用 CPU 的原因
我们正在JBOSS中使用oracle运行一个JAVA应用程序。我们使用了Seam和Hibernate框架。我们面临的问题是,当我们启动应用程序服务器时,CPU利用率增加,一小时后我们发现CPU利用率接近90% .这很奇怪,我无法确定问题所在。
请帮忙。提前致谢。
干杯, Dwarak
We are running a JAVA application in JBOSS with oracle.We have used Seam and Hibernate frameworks.The problem we are facing is,when we start tha application server the cpu utlizations increase and after one hour we found that CPU utilizaiton is close to 90%.It is bizarred and I am not able to identify the problem.
Please Help.Thanks in Advance.
Cheers,
Dwarak
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
理想情况下,您可以使用分析器来追踪问题。如果您无法在其所在的环境(例如生产环境)中使用探查器,请尝试在其他地方重现它并在那里附加探查器。但这通常很困难,所以这里有一个我多次使用过的技巧,用于从命令行查找生产中 CPU 使用率的原因:
如果您短时间观看此内容,您可能会看到一些常见的方法叫。接下来将完整的 jstack 输出获取到文件中:
现在在文件中搜索您经常看到的方法之一。从堆栈跟踪中,您通常可以找到负责 CPU 消耗的代码。如果没有任何显示,那么也许您的时间将用于过多的垃圾收集,您只需要增加内存即可。您可以使用:
更好地了解内存使用情况。更好的是,您可以附加 jvisualvm 或商业广告Profiler(例如 YourKit)随着时间的推移以图形方式查看它。我有时也使用过 watch -n1 'jmap -heap [pid]' 。
Ideally you can use a profiler to track down the problem. If you can't use a profiler in the environment it's in (like production) then try to reproduce it somewhere else and attach a profiler there. Often that can be difficult though, so here's a trick I've used a number of times to find the cause of CPU utilization in production from the command line:
If you watch this for a short period of time you might see some common methods being called. Next grab a full jstack output to a file:
Now search the file for one of the methods that you saw showing up frequently. From its stack trace you can usually find the code responsible for grinding the CPU. If nothing shows up then perhaps your time is going to excessive garbage collection and you simply need to increase memory. You can use:
To get a better idea of memory usage. Better yet you can attach jvisualvm or a commercial profiler (like YourKit) to see it graphically over time. I've also used
watch -n1 'jmap -heap [pid]'
on occasion.如果以上都没有帮助,那么最后的办法就是使用分析工具。我建议 JProfiler 或 Yourkit Profiler(商业版,但有 30 天试用期),它们非常用户友好。
If nothing above helps, the last resort is to go for a profiling tool. I suggest JProfiler or Yourkit Profiler (Commercial, but 30-day trail available) which is very user-friendly.
使用分析器来查找问题。如果使用 Oracle Java 6,请从 JDK 中的 jvisualvm 启动。
Use a profiler to find the problem. If using Oracle Java 6, start with jvisualvm in the JDK.