Tomcat Multi-Threading

Z

zigzagdna

I am using Apache Tomcat 6.x on a Windows 2003 Server R2. I can see Apache Tomcat is a multithreaded applications, no of threads arrange from 50 to 300. Since it is a multithreaded application, I am assuming that if add more CPU’s to box, it should improve performance because different CPU’s canrun different threads? Is my assumption correct?

I know some applications are single threaded, so adding more CPU’s does not really help, but in case of Tomcat, it should improve the performance.
 
A

Arne Vajhøj

I am using Apache Tomcat 6.x on a Windows 2003 Server R2. I can see
Apache Tomcat is a multithreaded applications, no of threads arrange
from 50 to 300. Since it is a multithreaded application, I am
assuming that if add more CPU’s to box, it should improve performance
because different CPU’s can run different threads? Is my assumption
correct?

If the CPU is the bottleneck then yes.

Arne
 
L

Lew

zigz...@ said:
I am using Apache Tomcat 6.x on a Windows 2003 Server R2. I can see Apache Tomcat is a multithreaded applications, no of threads arrange from 50 to 300. Since it is a multithreaded application, I am assuming that if add more CPU’s [sic] to box, it should improve performance because different CPU’s can run different threads? Is my assumption correct?

Only testing will tell.

Whenever it's an assumption it's probably false.
I know some applications are single threaded, so adding more CPU’s [sic] does not really help, but in case of Tomcat, it should improve the performance.

It "should"?

That's a strong statement given you have no evidence.

In the world of Java, no applications are single threaded.
 
A

Arne Vajhøj

In the world of Java, no applications are single threaded.

I think most people would consider a console app with no
threads to be single-threaded. Whether the JVM uses some
threads behind the scene for various purposes is a JVM
implementation detail.

Arne
 
Z

zigzagdna

On Tuesday, January 29, 2013 9:21:48 PM UTC-5, Arne Vajhøj wrote:


Arne:
Thanks a lot.
 
L

Lew

Arne said:
I think most people would consider a console app with no
threads to be single-threaded. Whether the JVM uses some
threads behind the scene for various purposes is a JVM
implementation detail.

A detail that is directly relevant to the OP's question about whether
multiple CPUs would enhance performance!

This is one scenario where you cannot merely wave your hands and pretend
the console app is single threaded, because if multiple CPUs do help performance
of multi-threaded Java programs, then they'll help that app, too.

In your rush to disagree you threw out the baby with the bath water.
 
M

Magnus Warker

I think most people would consider a console app with no
threads to be single-threaded.

There is even no relationship between a programming language and the
threading architecture of an application. The fact that Java supports
multi-threading does not lead to the fact that every Java application is
multi-threaded.

Magnus
 
L

Lew

Magnus said:
There is even no relationship between a programming language and the
threading architecture of an application. The fact that Java supports
multi-threading does not lead to the fact that every Java application is
multi-threaded.

No, the first fact does not lead to the second fact, but the second fact isnevertheless true.

The JVM is multi-threaded and has, what, a minimum of four? at any rate severa; threads running
even if the application only uses one of them.

Do a little research.
 
M

Magnus Warker

No, the first fact does not lead to the second fact, but the second fact is nevertheless true.

The JVM is multi-threaded and has, what, a minimum of four? at any rate severa; threads running
even if the application only uses one of them.

There is a mistake in your logical conclusion: Even if the VM is
multi-threaded, the applications running on top of them may still be
single-threaded. So your statement ("no applications are single
threaded") is simply wrong.

Magnus
 
J

jlp

Le 30/01/2013 18:04, Magnus Warker a écrit :
There is a mistake in your logical conclusion: Even if the VM is
multi-threaded, the applications running on top of them may still be
single-threaded. So your statement ("no applications are single
threaded") is simply wrong.

Magnus
Notice also that the OP talks about Tomcat and not directly a standalone
application.
Tomcat, is a servlet container can handle multiple http/https/AJP
connections with its ThreadPool ( if obviously this pool is not sized to
1). Naturally Web-apps are multi-Threaded.
 
L

Lew

Magnus said:
There is a mistake in your logical conclusion: Even if the VM is
multi-threaded, the applications running on top of them may still be
single-threaded. So your statement ("no applications are single
threaded") is simply wrong.

No, it isn't.

The Java application, from the OS perspective, comprises the JVM and everything it runs.

The application doesn't exist outside the context of the JVM, so such considerations matter.

Even more important, the OP wants to know if multiple CPUs will help performance of a
Java app if it's multithreaded. Since the app runs in a multi-threaded context, if multiple
CPUs would speed up a multi-threaded app, they'd help *any* Java app. I made this point
upthread; I guess you decided to ignore it in order to snark, huh?

Let's try to stay focused on the OP's concern here, shall we?
 
Z

zigzagdna

On said:
On 30/01/13 16:28, Lew wrote: > Magnus Warker wrote: >> Arne Vajhøj wrote: >>> Lew wrote: >>>> In the world of Java, no applications are single threaded. >>> I think most people would consider a console app with no >>> threads to be single-threaded. >> >> There is even no relationship between a programming language and the >> threading architecture of an application. The fact that Java supports >> multi-threading does not lead to the fact that every Java application is >> multi-threaded. > > No, the first fact does not lead to the second fact, but the second fact is nevertheless true. > > The JVM is multi-threaded and has, what, a minimum of four? at any rate severa; threads running > even if the application only uses one of them. I think you may be confusing the VM and the threads it uses to do housekeeping (garbage collection, assignment of execution threads to multiple processors etc) with the application running in the VM, which, unless you explicitly create a new Thread in your code will by default be single threaded. > Do a little research. Well quite lipska -- Lipska the Kat©: Troll hunter, sandbox destroyer and farscape dreamer of Aeryn Sun

Thanks a lot to all of your insight. I do not see any separate java processfor my "application". I only see tomcata6.exe which shows many threads, soI assuming my "application" is multi-theraded and more CPU's should help!!!
 
L

Lew

lipska said:
I think you may be confusing the VM and the threads it uses to do
housekeeping (garbage collection, assignment of execution threads to
multiple processors etc) with the application running in the VM, which,
unless you explicitly create a new Thread in your code will by default
be single threaded.

No, I'm not confusing them, I'm referring to them.
Well quite

You obviously have done the research, since you mentioned the very threads to
which I'm referring.

The OP's question, as I'm pointing out for the third time, has to do with whether
multi-core platforms will enhance performance if there are multiple threads. Since
every Java program involves multiple threads, it's reasonable to assume that any
effect that exists due to multiple CPUs would be relevant.
 
A

Arne Vajhøj

Thanks a lot to all of your insight. I do not see any separate java
process for my "application". I only see tomcata6.exe which shows
many threads, so I assuming my "application" is multi-theraded and
more CPU's should help!!!

It is correct that it is a single process with multiple threads.

Performance will be improved by adding more CPU's *if* the application
is CPU bound.

If you are currently using 10% of available CPU power, because all
threads are waiting for the database, then adding more CPU's will
not help.

If you are using 100% of available CPU power and the threads are
waiting to get the CPU, then adding more CPU's should help.

Arne
 
A

Arne Vajhøj

That's not necessarily the case. Whether more CPU cores will improve
an application's performance depends on how the application balances
CPU load across threads -- not just the number of threads it uses. If
an application uses 20 threads, but 19 of those spends almost all
their time waiting on work being done in the 20th thread, throwing
more cores at the application isn't going to make a measureable
difference.

But that is not a very likely scenario for a web app.

Arne
 
A

Arne Vajhøj

A detail that is directly relevant to the OP's question about whether
multiple CPUs would enhance performance!

This is one scenario where you cannot merely wave your hands and pretend
the console app is single threaded, because if multiple CPUs do help performance
of multi-threaded Java programs, then they'll help that app, too.

In your rush to disagree you threw out the baby with the bath water.

That comment was specifically towards you claim that there were
no single threaded apps in Java.

The discussion is not relevant for OP as he has very multi threaded
app.

Arne
 
A

Arne Vajhøj

No, the first fact does not lead to the second fact, but the second fact is nevertheless true.

The JVM is multi-threaded and has, what, a minimum of four? at any rate severa; threads running
even if the application only uses one of them.

The JVM does not have a specific number of threads. The specific JVM you
are using have a specific number of threads.

The fact that some JVM's start extra threads does not make all
Java apps multi threaded.

Arne
 
A

Arne Vajhøj

No, it isn't.

The Java application, from the OS perspective, comprises the JVM and everything it runs.

The application doesn't exist outside the context of the JVM, so such considerations matter.

As you can write runtimes and runtime libs that start threads for any
language, then you logic of "some JVM's start threads => Java
applications are always multi threaded" implies that it is
only possible to write single threaded apps in languages
like assembler where you can control exactly what happens.

That is of course a perfectly consistent terminology.

But it is not the terminology used in the IT industry.

A multi threaded app in common terminology is where the application
itself contains code that result in threads being started.

Arne
 
A

Arne Vajhøj

No, I'm not confusing them, I'm referring to them.


You obviously have done the research, since you mentioned the very threads to
which I'm referring.

The OP's question, as I'm pointing out for the third time, has to do with whether
multi-core platforms will enhance performance if there are multiple threads. Since
every Java program involves multiple threads, it's reasonable to assume that any
effect that exists due to multiple CPUs would be relevant.

The effect of multi core from just the house keeping threads would
not be that big.

But I don't think anyone argued against that multi core is good for
Java in general (besides the JVM house keeping threads a modern OS
usually runs dozens of other processes).

What we are skeptical about is you claim that all Java apps
are multi threaded. That seems to be based on a rather unsual
definition of multi threaded.

Arne
 
M

Magnus Warker

Even more important, the OP wants to know if multiple CPUs will help performance of a
Java app if it's multithreaded. Since the app runs in a multi-threaded context, if multiple
CPUs would speed up a multi-threaded app, they'd help *any* Java app. I made this point
upthread;

I can only repeat what others already pointed out:

You are confusing multi-threading in java applications and processes
that are multi-threaded from the os perspective.
I guess you decided to ignore it in order to snark, huh?

This is your job.

Magnus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top