tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: Tomcat threads
Date Wed, 12 Nov 2008 14:12:46 GMT
Hash: SHA1


André Warnier wrote:
> - The memory usage one sees with "top" under some versions of Linux for
> each one of these threads is not really cumulative, because most of it
> is actually shared between the threads.  The total really used is only
> slightly more than what is indicated individually for each thread.
> In other words, after the first thread is created, each additional
> thread only adds a relatively small overhead.

Actually, it gets better than that if you have multiple 1.5+ JVMs
running on the same machine (*NIX /or/ Windows), since recent JVMs use
shared memory to share common class data (like JITed object code from
java.* packages). So, the OS helps share data between JVMs if you have
several of them running.

> Now let me elaborate one step further, and let me know if this is correct :
> If in a Tomcat I have one HTTP Connector and one AJP Connector (used
> with mod_jk), they are two distinct Connectors. (I don't really expect
> dissent here, but who knows ?)
> Each one will create new threads as needed to service requests on *that*
> Connector, independently of the other Connector.


> So if I access the same application (webapp) multiple times
> indifferently through one Connector or the other, this will result in
> two groups of threads, one group per Connector, each group behaving
> independently like indicated above in the summary. Right ?


> If right, then it means one would do better choosing if one can, and
> always access this application through either one of the Connectors, but
> not both, right ?

Mmm.... maybe. I would argue that memory and thread count aren't the
proper reasons for picking just one connector and sticking with it, but
I round recommend that configuration anyway: why bother with AJP when
HTTP is working for you? Or, if you are using AJP for some stuff, why
add the (likely) headache of exposing HTTP as well?

> Or, considering both groups are in the end executing the same webapp
> application, would the memory used by the two groups of threads end up
> being largely shared also anyway ?

Yes, the memory is shared. It doesn't matter where the Thread objects
came from, they all have the same heap. Even if they are serving
/different/ applications, it doesn't matter (because threads are not
app-specific). About the only thing they don't share (as Chuck
mentioned) is their stack and some small amount of private memory
(probably around 1MB or less).

- -chris
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla -


To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message