views:

587

answers:

3

Hi,

We noticed a peculiar behavior with Java/Web Logic on one of our multi-processor servers, yesterday, so wanted to get your thoughts on it.

For some reason, Web Logic/Java use only one processor of the available two processors. When we ran some heavy load, I could see the CPU on one reaching almost 100% and the other processor is completely idle. Does it matter if this is a virtual machine (..but this is not a virtual machine)

Interesting thing is that any other OS-activities indicate processor activity on both.

Regards, _UB

A: 

The WebLogic docs give advice on how to configure for multi-processor machines. You'd end up with a clustered environment.

duffymo
Oh come on, you really don't need to configure a clustered environment to be able to use multiple processors in a Java application! All Java app servers handle request processing with concurrent threads by default. Only way to circumvent this is to either use single-threaded servlet model (a developer decision, although mostly bad one) or to limit request processing threads to 1 (=ridiculous).
Kaitsu
No indication about single thread model, so I'm assuming that the questioner wasn't so foolish as to go that way. Since the WebLogic docs themselves refer to special handling needed for multi-processor machines, the original question indicates that multi-processors are not used out of the box, and multi-threads are not the same as multi-processors, I'll stand by my original answer until better information comes along.
duffymo
@duffymo: Sorry, if my comment sounded rude. I just wanted to make my point clear. :)
Kaitsu
No worries, Kaitsu. Change your mind about the down vote then, or does that still stand as well?
duffymo
Don't you mean http://download.oracle.com/docs/cd/E13222_01/wls/docs81/perform/WLSTuning.html or http://download.oracle.com/docs/cd/E12840_01/wls/docs103/perform/WLSTuning.html
Pascal Thivent
+1  A: 

In common scenarios, WebLogic (and thus Java) should be able to use all the available processors in the server where it's running. WebLogic has a pool of request processing threads and when requests are arriving concurrently, they are handled concurrently. If the server has multiple processors those should be then used by Java threads.

If the Java web application running in WebLogic is using SingleThreadModel in its servlet(s), no two threads can execute the servlet concurrently and thus you could see only one CPU at work there. This model is not recommended and I guess not much used anyway.

I've heard some people complaining that they cannot get their Java app servers to use more than 1 CPU when running a virtual machine OS, like VMWare, even when they have dedicated more than one CPU for the VM. I have no idea what was the reason for this strange behavior then.

Maybe you should try to hit some very simple JSP page with concurrent requests and see if more than 1 CPU is being used. If this works, the problem is in your application.

Kaitsu
"I've heard some people complaining that they cannot get their Java app servers to use more than 1 CPU when running a virtual machine OS, like VMWare, even when they have dedicated more than one CPU for the VM. I have no idea what was the reason for this strange behavior then." - kinda like the original poster, right? This is what you call a helpful answer? Please.
duffymo
@duffymo: Well, the part that you quoted from my answer was just an addition to the actual answer, which at least contained something concrete compared to your suggestion to start reading WebLogic docs on how to start clustering WL. That's like shooting a fly with a big cannon when the problem is just to get a an application to run with multiple processors, which by the way, is very common in Java web applications. Peace.
Kaitsu
@Kaitsu, BEA disagrees with you, and the data posted by the questioner says that your way isn't working. That's the whole reason for the question. You keep insisting that it simply works, and that the application that you haven't seen is at fault, but the data doesn't support your view. I fully understand that Java web apps are multi-threaded; no disagreement there. But it's one JVM per CPU for WebLogic and JBOSS and other Java EE app servers that I use. I believe it's more than multi-threading. It's shared state for stateful EJBs, sessions, load balancing, etc.
duffymo
@duffymo: It surely isn't one JVM per CPU for WebLogic (or any other Java EE server for that matter), or can you show us any proof of that? Your link to the WebLogic documentation didn't say anything about CPUs. If one JVM per CPU would be the case, you would need 4 JVMs to fully utilize a 4-CPU server and that just doesn't make any sense. I have used and built plenty of Java web applications and witnessed with my own eyes how beautifully a Java server process utilizes all the CPUs in the system.
Kaitsu
Some Resin users seem to experience same kind of problems like reported here, but Resin creator Scott Ferguson claims that they cannot reproduce it and it shouldn't work that way. See more here: http://bugs.caucho.com/view.php?id=3465
Kaitsu
A: 

Is your workflow single threaded? Which OS are you running?

Javamann
Win 2003 Server, multi threaded
UB