aspose file tools*
The moose likes Tomcat and the fly likes Tomcat CPU utilization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat CPU utilization" Watch "Tomcat CPU utilization" New topic
Author

Tomcat CPU utilization

Alpesh Gediya
Greenhorn

Joined: Nov 23, 2009
Posts: 24
Hello friends..


we are using tomcat 5.5.27. We are facing strange problem. Tomcat CPU utilization goes high .
Once i restart Tomcat it works fine for 15-20 days after that i start consuming more CPU.

Please help me on this.
Thanks and Regards
Alpesh Gediya


Alpesh Gediya
Do not re-invent the wheel.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16142
    
  21

Don't blame Tomcat. It has no such history. One of your apps is going off the deep end. You'll need to apply some performance measuring tools to find out which one and how.


Customer surveys are for companies who didn't pay proper attention to begin with.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12805
    
    5
The management tool would be the first thing I would use. It shows the condition of ALL request Threads.

When my Tomcat ran out of Threads the management tool showed that a number of requests had been stuck processing for hours and days. Turned out that they were waiting for a socket connection with a service that was off.

Note that the management app is not part of the standard download for security reasons.

Bill
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16142
    
  21

William Brogden wrote:

Note that the management app is not part of the standard download for security reasons.

Bill


However, jconsole comes with the JDK, and while it's not conversant with the specifics of Tomcat in particular, it can give very fined-grained data on Tomcat. Or any other running JVM(s).
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12805
    
    5
On the other hand, the management app gives the originating IP for each request, the running time so far, plus the actual request 1st line - this may give a clue as to which function is causing a problem.

Bill
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Alpesh Gediya wrote:Once i restart Tomcat it works fine for 15-20 days after that i start consuming more CPU.


Why don't you introduce scheduled tomcat restart?
Kees Jan Koster
JavaMonitor Support
Rancher

Joined: Mar 31, 2009
Posts: 251
    
    5
Misha Ver wrote:Why don't you introduce scheduled tomcat restart?


Because it is 2009 and such actions are lame?

Here's what you can do: periodically (daily) make a thread dump and compare the dumps you make during normal operation with the dumps you make during days when CPU usage is high.

http://java-monitor.com/forum/showthread.php?t=616
http://java-monitor.com/forum/showthread.php?t=317

Also, there is a chance that your app has a slow memory leak. Use a monitoring tool to see what your garbage collectors are doing and if you have enough free memory during times when CPU usage is high.

http://java-monitor.com/install.html

Kees Jan


Java-monitor, JVM monitoring made easy <- right here on Java Ranch
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6662
    
    5

Misha Ver wrote:
Alpesh Gediya wrote:Once i restart Tomcat it works fine for 15-20 days after that i start consuming more CPU.


Why don't you introduce scheduled tomcat restart?


Because customers will kill you when they find that their session is lost.

A load test should do a good job at revealing any problems. Use Apache JMeter or tailor some test cases with Selenium.

Thread dumps / logs / Resource charts will be of great help. But do you really want to wait for the next big bang ?


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Kees Jan Koster wrote:
Misha Ver wrote:Why don't you introduce scheduled tomcat restart?


Because it is 2009 and such actions are lame?


It depends. If you have time and resources, you could start tracking down the issue. In this particular case, the scheduled tomcat restart could be much cheaper and faster solution.
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Deepak Bala wrote:
Misha Ver wrote:
Alpesh Gediya wrote:Once i restart Tomcat it works fine for 15-20 days after that i start consuming more CPU.


Why don't you introduce scheduled tomcat restart?


Because customers will kill you when they find that their session is lost.


Do you want to say that there is no way to set up Tomcat environment in the way that users would not notice restart?
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6662
    
    5

Misha Ver wrote:
Deepak Bala wrote:
Misha Ver wrote:
Alpesh Gediya wrote:Once i restart Tomcat it works fine for 15-20 days after that i start consuming more CPU.


Why don't you introduce scheduled tomcat restart?


Because customers will kill you when they find that their session is lost.


Do you want to say that there is no way to set up Tomcat environment in the way that users would not notice restart?


It is not a smart way to do it. You can discuss the pros and cons in a separate thread though. This thread is about tomcat CPU utilization
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Deepak Bala wrote:It is not a smart way to do it. You can discuss the pros and cons in a separate thread though. This thread is about tomcat CPU utilization


Deepak, my question to you was a rhetorical question. I'm not the one who asked about CPU utilization, but as usual, the answer is "it depends". We do not know in what environment Alpesh works, but perhaps his customers would not kill him for restarting Tomcat.
Alpesh Gediya
Greenhorn

Joined: Nov 23, 2009
Posts: 24
Restarting Tomcat at scheduled time is not possible because there are more than 600+ client remains connected 24X7.

Can you please name me some good Perfomance tools?
Can anybody tell me best practice for Thread DUMP..

Thanks
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16142
    
  21

... but perhaps his customers would not kill him for restarting Tomcat.


But I seriously would consider doing so.

Arbitrary restarts as a permanent solution to a problem is pure "Git 'R Dun" engineering. It's not a solution, it's a hack. And every time you hack your way out of a problem, it becomes that much more acceptable to break out the axe and hack your way out of the next one as well.

Computers and IT (then called "Data Processing") started off as infallible ("Computers don't make mistakes") resources, executing their tasks with machine-like (like??) precision. These days, the exact opposite point of view prevails. IT is perceived as a sloppy endeavour where everything is broken and whatever we pay for it is too much since no one delivers anyway, so we might as well get the cheapest talent we can.

Have you ever seen the classic "clown fire department" circus act? The clowns are attempting to put out a fire (typically in a house with a baby in it), but they're so ill-co-ordinated and inefficient, that the water goes everywhere but the fire, the rescue trampoline is in the wrong place at the wrong time, and so forth and so on.

That's modern-day Information "Technology".

It shouldn't be that way. Like the saying goes - never time to do it right, always time to do it over. Except that eventually you spend so much of your time doing things over that things never get done at all. And we get no respect.

And deserve none. As I've said before, the difference between a craftsman and a slave is that when a craftsman is presented with a job which has unrealistic expectations, he will object. A slave will just accept them and do as little as possible. But slave labor isn't appropriate for precision work.

We have both external and internal forces to blame for this situation: what I call the "All You Have To Do Is..." syndrome, where both users and developers have unrealistic expectations of the time, effort, and expense involved in getting a machine to do things that would be obviously to even the densest human.

The only way to become a profession and a craft is to act like we belong to a profession and a craft. Put away the duct tape. Push back, despite the pressure. Stand up, not only for your rights, but the rights of the profession as a whole. Get out of the clown fire department and FIX things!

The pressure is a race to the bottom, and I realize that the pressure is extreme, especially in these straitened times, but if we never deliver anything but hatchet work, we'll never be expected to be capable of better.

They'll end up expecting us to work for 5000 rupees a year. And that's just about what we'll be worth.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12805
    
    5
Alpesh - have you tried the Management application like I suggested earlier?

Once installed it is easy to use and will continue to be helpful after you solve your current problem.

Bill
 
wood burning stoves
 
subject: Tomcat CPU utilization