• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Want the freeware/licence tool which kill those process which cause more cpu usage

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

Sometime our tomcat use 100% CPU usage,
So we want free up some cpu usage by killing some thread process which is running by deployed web application in that tomcat
I want the tool , which kill those thread process running in tomcat container

I had search in net , but not get any proper information on this

please give me the link,name,reference details for those all tools
i want the demo for it if possible,
Please some body share your knowledge in this regards

Our environment is
Apache server 2.2
Tomcat 7
Java 1.7
Struts 2.2

and we had deployed web application in tomcat 7

Let me know if you want any other information from our side

Thanks
Yatin Baraiya

 
Rancher
Posts: 43009
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is a bad idea. The proper course of action is to investigate what the treads are doing, whether that is or is not correct, and if it is not, to fix the code accordingly.
 
Bartender
Posts: 20842
125
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Thread.kill method was deprecated long, long ago because external termination of Threads at random points in the thread execution can badly corrupt the application. The recommended method these days is to create threads that can sense when an external client wants the thread to stop what it is doing and shut itself down and clean itself up.

You do not own the threads in Tomcat, so forcibly killing them is a very, very, very bad idea. Tomcat has 2 primary thread pools. One of them manages the threads that listen for incoming requests, the other manages the threads that service requests (that is, they run the servlets and JSPs). These threads are constantly being re-used, so if you kill one, it cannot be returned to its Thread Pool and you will have corrupted Tomcat.


Note that per the J2EE standard, JSPs, servlets, and EJBs are expressly forbidden from spawning child threads. That is because once attached to a pool thread, the pool thread will no longer be interchangeable with any other pool thread, the child thread will not be properly manageable, and the overall results are unpredictable. Except that I can predict a fairly high probability that Tomcat will eventually crash.
 
yatin baraiya
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you both are right

can any one suggest me the tools for it which excatly point out the my java code which cause more CPU usage, so i can easily investigate those things?

Share me if you have any freeware/liceneced tool name,link etc...



 
Tim Holloway
Bartender
Posts: 20842
125
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JDK comes with a number of tools. JConsole, for example.

I have a relatively crude way of detecting greedy threads under Tomcat when using Eclipse as a debugger. I simply pause threads until the CPU load goes away. The thread that I paused is the CPU consumer, and as a bonus, I get a stack trace on where in the thread current execution is, which helps me home in on the offending application code.
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is another way to detect greedy threads using the tools that Java has, and doesn;t require a debugger or manually pausing one thread at a time. SImply take couple of thread dumps and look at the active threads. Not only does it tell you which threads are active, but they also tell you what exactly they are doing. It's as good as pausing all the threads without actually pausing them :p

ETA: And.. there is an "old school" way of doing CPU profiling without using a profiler. I have done it in a production environment that was restricted from being connected via debugger/JMX. Take 20 thread dumps, once a second, and you get a good picture of what the CPU is doing in those 20 seconds. You have to manually match up the thread across thread dumps but it gives a fairly accurate picture

BTW, behind the scenes that's exactly what VisualVM does.. keep taking thread dumps, analyze them and put them together
 
yatin baraiya
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i do not want to depend on thread dump way, is there any tool which really help me out in this regards?
debugging, thread dump,jconsole,visualVm everything we had try , but now onwards , we looking perfect tool for it,
as above not giving any perfect root cause for it
 
Ulf Dittmer
Rancher
Posts: 43009
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How, exactly, have you used those tools, and what have you found out so far? Tools are only part of the answer ; the other part is logical reasoning about the code and experimentation on your part.
 
yatin baraiya
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:How, exactly, have you used those tools, and what have you found out so far? Tools are only part of the answer ; the other part is logical reasoning about the code and experimentation on your part.



I will use this tool to identify my java source code line which cause more CPU usage, i had sample java program ,which cause more cpu usage , so i will call this java program method from one of my servlet service ,and i will expect that tool will point out this code which cause more CPU usage ,and from that i will get the full confirmation and get verification for this tool usages for monitoring my web application,
and from that i will get the root cause of my cpu usage , according to that we will provide the fix for related issue in features

 
Ulf Dittmer
Rancher
Posts: 43009
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It won't work like that. If your code had a section that was by itself CPU-intensive you would likely already know about it. It is much more likely to be caused by a coincidence of several factors, which you will have to tease out by reasoning and experimentation. I advise to let go of the hope that you can somehow avoid that.
 
yatin baraiya
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:It won't work like that. If your code had a section that was by itself CPU-intensive you would likely already know about it. It is much more likely to be caused by a coincidence of several factors, which you will have to tease out by reasoning and experimentation. I advise to let go of the hope that you can somehow avoid that.



hi ilf dittmer
i had just giving the example for it , there has been some other code in this, and i am not aware about all those code which cause more CPU usage , if possible then please suggest me those tools,
at least it pointing me the java method level , then also it should be useful for me

 
Ulf Dittmer
Rancher
Posts: 43009
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems I'm not getting my point across: such tools as you're looking for do not exist, certainly not as freeware. If you're looking for more than what VisualVM et al. offer, you will have to resort to commercial options. jClarity might be worth checking out.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!