views:

202

answers:

3

We have an enterprise java application(ear - few ejb's and a webapp) deployed on to weblogic 10 and using Sun java 5. The response time , CPU and memory usage is fine under few users of load but if we increase the concurrent users to >100 we see huge CPU spikes after some time (for eg:- load test with 100 users, the CPU goes to high after more than 30 minutes of test). We wanted to use hprof to profile the app and collect the statistics, but wanted to do it only when CPU is high i.e after 3o minutes of the test, is there a way to do it?

I cannot use jmap because we are using Sun java 5.

A: 

This is intrinsicly JVM specific. Hence you need to specify which JVM you use (Sun/BEA/IBM etc).

While figuring that out, consider setting the session timeout in your webcontainer down to 60 seconds and rerun the test.

Thorbjørn Ravn Andersen
A: 

If nothing else, a couple of options you could try are:

  • when CPU is going high, just do CTRL+BREAK a few times and see if you can "eyeball" where the threads tend to be (on UNIX to do this, you call kill on the process with a signal number that temporarily escapes my mind);
  • with hprof, just profile over the whole time anyway and see if it offers clues anyway-- if it's the bit where the CPU is high that you're interested in, then that may take up the majority of the time even if you were initially running for a while with low CPU;
  • from your program itself, consider using some of the thread profiling calls available via ThreadMXBean.

I appreciate the latter isn't everybody's cup of tea, but it will ultimately allow you to do what you want to do.

Neil Coffey
+1  A: 

Huge spikes in CPU can be an indication the GC is running. If so, this will not show up in the profiler. You can run with the -verbosegc to see when the GC is running. (Or use jconsole)

Peter Lawrey