Tomcat Multi-Threading

Discussion in 'Java' started by zigzagdna@yahoo.com, Jan 30, 2013.

  1. Guest

    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.
    , Jan 30, 2013
    #1
    1. Advertising

  2. Arne Vajhøj Guest

    On 1/29/2013 8:59 PM, wrote:
    > 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
    Arne Vajhøj, Jan 30, 2013
    #2
    1. Advertising

  3. Lew Guest

    zigz...@ wrote:
    > 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.

    --
    Lew
    Lew, Jan 30, 2013
    #3
  4. Arne Vajhøj Guest

    On 1/29/2013 9:31 PM, 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. Whether the JVM uses some
    threads behind the scene for various purposes is a JVM
    implementation detail.

    Arne
    Arne Vajhøj, Jan 30, 2013
    #4
  5. Guest

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


    Arne:
    Thanks a lot.
    , Jan 30, 2013
    #5
  6. Lew Guest

    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. 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.

    --
    Lew
    Lew, Jan 30, 2013
    #6
  7. On 01/30/2013 03:39 AM, Arne Vajhøj wrote:
    > On 1/29/2013 9:31 PM, 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.

    Magnus
    Magnus Warker, Jan 30, 2013
    #7
  8. Lew Guest

    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 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.

    --
    Lew
    Lew, Jan 30, 2013
    #8
  9. On 01/30/2013 05:28 PM, 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.


    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
    Magnus Warker, Jan 30, 2013
    #9
  10. jlp Guest

    Le 30/01/2013 18:04, Magnus Warker a écrit :
    > On 01/30/2013 05:28 PM, 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.

    >
    > 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.


    --
    Cordialement
    Jean-Louis Pasturel
    jlp, Jan 30, 2013
    #10
  11. Lew Guest

    Magnus Warker wrote:
    > 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 factis 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.


    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?

    --
    Lew
    Lew, Jan 30, 2013
    #11
  12. Guest

    On Wednesday, January 30, 2013 12:49:24 PM UTC-5, lipska the kat wrote:
    > 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!!!
    , Jan 30, 2013
    #12
  13. Lew Guest

    lipska the kat wrote:
    >Lew wrote:
    >>>>> In the world of Java, no applications are single threaded.

    > 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.

    >> Do a little research.

    >
    > 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.

    --
    Lew
    Lew, Jan 30, 2013
    #13
  14. Arne Vajhøj Guest

    On 1/30/2013 2:29 PM, wrote:
    > 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
    Arne Vajhøj, Jan 31, 2013
    #14
  15. Arne Vajhøj Guest

    On 1/30/2013 3:30 PM, Leif Roar Moldskred wrote:
    > wrote:
    >> 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!!!

    >
    > 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
    Arne Vajhøj, Jan 31, 2013
    #15
  16. Arne Vajhøj Guest

    On 1/30/2013 1:54 AM, Lew 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. 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.


    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
    Arne Vajhøj, Jan 31, 2013
    #16
  17. Arne Vajhøj Guest

    On 1/30/2013 11:28 AM, 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.


    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
    Arne Vajhøj, Jan 31, 2013
    #17
  18. Arne Vajhøj Guest

    On 1/30/2013 12:49 PM, Lew wrote:
    > Magnus Warker wrote:
    >> 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.

    >>
    >> 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.


    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
    Arne Vajhøj, Jan 31, 2013
    #18
  19. Arne Vajhøj Guest

    On 1/30/2013 5:48 PM, Lew wrote:
    > lipska the kat wrote:
    >> Lew wrote:
    >>>>>> In the world of Java, no applications are single threaded.

    >> 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.
    >
    >>> Do a little research.

    >>
    >> 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.


    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
    Arne Vajhøj, Jan 31, 2013
    #19
  20. On 01/30/2013 06:49 PM, Lew wrote:
    > Magnus Warker wrote:
    >> Lew wrote:


    >>> 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.


    > 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
    Magnus Warker, Feb 1, 2013
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joe
    Replies:
    0
    Views:
    1,663
  2. Replies:
    38
    Views:
    1,256
    Dennis Lee Bieber
    Feb 15, 2005
  3. Replies:
    9
    Views:
    1,011
    Mark Space
    Dec 29, 2007
  4. Steven Woody
    Replies:
    0
    Views:
    394
    Steven Woody
    Jan 9, 2009
  5. akineko
    Replies:
    3
    Views:
    2,597
    Jesse Noller
    Jan 29, 2009
Loading...

Share This Page