You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Endre Stølsvik <En...@Stolsvik.com> on 2000/12/22 16:32:42 UTC

Tomcat threads..

I'm trying desperately to get tomcat to use only ONE thread. But I always
seem to end up with 10 or so..

I guess this is because of tomcat internals, but just how many threads
does tomcat really need?

-- 
Mvh,
Endre


Re: Tomcat threads..

Posted by Endre Stølsvik <En...@Stolsvik.com>.
On Sun, 24 Dec 2000, Kief Morris wrote:

| Endre Stølsvik typed the following on 09:23 PM 12/23/2000 +0100
| >| > I'm trying desperately to get tomcat to use only ONE thread. But I always
| >| > seem to end up with 10 or so..
| >
| >Yes, this is only for development purposes. I have a bunch of separate
| >server setups on one box, one for each developer (because of the not
| >working at all reload issue on tomcat 3.2).
| >  Only one guy is using each tomcat, so the whole point is that I don't
| >want a bunch of threads doing nothing.
| 
| Why not?

Because it annoys me?!

| It seems to me you're spending a lot of effort chasing a red herring.
| Are you worried about the performance impact of unnecessary threads?
| What makes you think reducing it down to a single thread would make
| a noticeable difference on your box? I'm skeptical that it would.

OK, ok, I'll let it go, then.. :-)

(Linux "process-threads" DO use resources though. I'm now trying green
threads! :)

The main reason is that I kind of wondered if my configuration really was
working, me specifying max 3 threads, while getting 10-12. So, again,
Tomcat really uses about 10 "background threads"? If so, I'm OK with that.


Merry christmas! Just taking a slight break from all the Christmas fat!

Endre.


Re: Tomcat threads..

Posted by Kief Morris <ki...@bitbull.com>.
Endre Stølsvik typed the following on 09:23 PM 12/23/2000 +0100
>| > I'm trying desperately to get tomcat to use only ONE thread. But I always
>| > seem to end up with 10 or so..
>
>Yes, this is only for development purposes. I have a bunch of separate
>server setups on one box, one for each developer (because of the not
>working at all reload issue on tomcat 3.2).
>  Only one guy is using each tomcat, so the whole point is that I don't
>want a bunch of threads doing nothing.

Why not?

It seems to me you're spending a lot of effort chasing a red herring.
Are you worried about the performance impact of unnecessary threads?
What makes you think reducing it down to a single thread would make
a noticeable difference on your box? I'm skeptical that it would.

In my experience, the biggest resource drain of running multiple JVMs 
and multiple instances of Tomcat is memory - memory usage probably 
has at least 100-1000 times more of an impact on the performance of your 
box than the number of threads. Get your developers to focus on keeping
memory usage down and you'll get a much bigger reward for your efforts
than worrying about the threaded architecture of Tomcat.

If threads are really keeping you awake at night, the best you can do
is cut down on the connector threads:

<Connector className="org.apache.tomcat.service.PoolTcpConnector">
    <Parameter name="handler" value="org.apache.tomcat.service.http.HttpConnectionHandler"/> 
    <Parameter name="port" value="8080"/> 
    <Parameter name="max_threads" value="2"/>
    <Parameter name="max_spare_threads" value="2"/>
    <Parameter name="min_spare_threads" value="1" /> 
</Connector> 

There are still going to be other threads - Tomcat is a threaded application.
There's not much you can do about it.

Kief
---
Kief Morris
Director of Technology
bitBull Ltd. http://www.bitBull.com
phone +44 020 7598 9938 
fax  +44 020 7460 4081



Re: Tomcat threads..

Posted by Endre Stølsvik <En...@Stolsvik.com>.
On Fri, 22 Dec 2000, Craig R. McClanahan wrote:

| Endre Stølsvik wrote:
| 
| > I'm trying desperately to get tomcat to use only ONE thread. But I always
| > seem to end up with 10 or so..
| >
| > I guess this is because of tomcat internals, but just how many threads
| > does tomcat really need?
| >
| 
| Tomcat needs one thread for each simultaneous request you want it to be able to
| handle, plus a few assorted background threads (such as checking for expired
| sessions).
| 
| Even if you modified Tomcat to use only one thread, you would be terribly
| disappointed with the performance.  Consider that most browsers (by default)
| will initiate multiple requests, even for a single user, to retrieve images on
| that page.

Yes, this is only for development purposes. I have a bunch of separate
server setups on one box, one for each developer (because of the not
working at all reload issue on tomcat 3.2).
  Only one guy is using each tomcat, so the whole point is that I don't
want a bunch of threads doing nothing.

I'm wondering about how that threadpool is working (I set it up with max
3, 0 min_spare and 1 max_spare. But I still got around 10-12 threads
(Linux ps shows this because of the hack linux uses for threads)). Just
how many background threads is tomcat actually using?

Thanks!

-- 
Mvh,
Endre


Re: Tomcat threads..

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Endre Stølsvik wrote:

> I'm trying desperately to get tomcat to use only ONE thread. But I always
> seem to end up with 10 or so..
>
> I guess this is because of tomcat internals, but just how many threads
> does tomcat really need?
>

Tomcat needs one thread for each simultaneous request you want it to be able to
handle, plus a few assorted background threads (such as checking for expired
sessions).

Even if you modified Tomcat to use only one thread, you would be terribly
disappointed with the performance.  Consider that most browsers (by default)
will initiate multiple requests, even for a single user, to retrieve images on
that page.

>
> --
> Mvh,
> Endre

Craig McClanahan



Re: Tomcat threads..

Posted by Thom Park <tp...@inprise.com>.
I'm sure your right - I haven't used the linux kernel in a long time
(Blackdown jdk days)

It used to be a heavyweight threading model for linux native threads but
there's been a whole lot
of improvements in the java threading implementations on linux (shame I
can't say the same for C/C++ threads)

I stand corrected :)

-T.

Ted Husted wrote:

> Ted Husted wrote:
> > As an aside, threads are not the same as an OS processes, although
> they can look the same.
>
> On 12/22/2000 at 9:20 AM Thom Park wrote:
> >...unless you're on a linux box ;-)
>
> Hmmm, it was my understanding that the Linux ps command was
> mis-reporting threads as processes.
>
> <
> http://www.mail-archive.com/tomcat-user@jakarta.apache.org/msg00639.html
>  >
> <
> http://www.mail-archive.com/tomcat-user@jakarta.apache.org/msg00583.html
>  >
>
> Let me know if I've got this wrong.
>
> -- Ted Husted, Husted dot Com, Fairport NY USA.
> -- Custom Software ~ Technical Services.
> -- Tel 716 425-0252; Fax 716 223-2506.
> -- http://www.husted.com/


Re: Tomcat threads..

Posted by Ted Husted <ne...@husted.com>.
Ted Husted wrote:
> As an aside, threads are not the same as an OS processes, although
they can look the same.

On 12/22/2000 at 9:20 AM Thom Park wrote:
>...unless you're on a linux box ;-)

Hmmm, it was my understanding that the Linux ps command was
mis-reporting threads as processes. 

<
http://www.mail-archive.com/tomcat-user@jakarta.apache.org/msg00639.html
 >
<
http://www.mail-archive.com/tomcat-user@jakarta.apache.org/msg00583.html
 >

Let me know if I've got this wrong.

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 425-0252; Fax 716 223-2506.
-- http://www.husted.com/



Re: Tomcat threads..

Posted by Thom Park <tp...@inprise.com>.

Ted Husted wrote:

>
> As an aside, threads are not the same as an OS processes, although they
> can look the same.
>

...unless you're on a linux box ;-)

-T.



Re: Tomcat threads..

Posted by Ted Husted <ne...@husted.com>.
On 12/22/2000 at 4:32 PM Endre St�lsvik wrote:
> I'm trying desperately to get tomcat to use only ONE thread. 

Why? Java and Tomcat are designed to be multithreaded. Reducing threads
would hurt performance. All the same resources would be used, but only
in serial. What is your goal?

As an aside, threads are not the same as an OS processes, although they
can look the same.


-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 425-0252; Fax 716 223-2506.
-- http://www.husted.com/