You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Pa...@groupe-asten.fr on 2002/10/28 14:10:22 UTC

TOMCAT memory usage : how to manage and benchmark ?

Hello,

I have tomcat 4.1.10 on a red hat Linux server 7.3 with the j2sdk141,

When I start the tomcat4 service, all is OK and the tomcat server run.

BUT, when I look the memory usage (with TOP utility), I have this result :

 11:31am  up 12 days,  2:18,  2 users,  load average: 0,00, 0,00, 0,00
90 processes: 87 sleeping, 3 running, 0 zombie, 0 stopped
CPU states:  0,0% user,  0,5% system,  0,0% nice, 99,4% idle
Mem:   514340K av,  479748K used,   34592K free,       0K shrd,   75716K
buff
Swap: 1048120K av,   35016K used, 1013104K free                  216648K
cached

  PID USER     PRI  NI  SIZE  RSS SHARE STAT %CPU %MEM   TIME COMMAND
19954 tomcat4   25   0 33584  32M 10464 S     0,0  6,5   0:05 java
19957 tomcat4   15   0 33584  32M 10464 S     0,0  6,5   0:00 java
19958 tomcat4   15   0 33584  32M 10464 S     0,0  6,5   0:00 java
19959 tomcat4   15   0 33584  32M 10464 S     0,0  6,5   0:00 java
19960 tomcat4   15   0 33584  32M 10464 S     0,0  6,5   0:00 java
19961 tomcat4   15   0 33584  32M 10464 R     0,0  6,5   0:00 java
19962 tomcat4   20   0 33584  32M 10464 S     0,0  6,5   0:00 java
19963 tomcat4   16   0 33584  32M 10464 S     0,0  6,5   0:00 java
19964 tomcat4   16   0 33584  32M 10464 S     0,0  6,5   0:01 java
19966 tomcat4   15   0 33584  32M 10464 S     0,0  6,5   0:00 java
19967 tomcat4   15   0 33584  32M 10464 S     0,0  6,5   0:00 java
19968 tomcat4   15   0 33584  32M 10464 S     0,0  6,5   0:00 java
19969 tomcat4   15   0 33584  32M 10464 S     0,0  6,5   0:00 java
19970 tomcat4   15   0 33584  32M 10464 S     0,0  6,5   0:00 java
19971 tomcat4   15   0 33584  32M 10464 S     0,0  6,5   0:00 java
19972 tomcat4   15   0 33584  32M 10464 S     0,0  6,5   0:00 java
19973 tomcat4   15   0 33584  32M 10464 S     0,0  6,5   0:00 java

So,

My first question is : why tomcat use all the memory while there is no
users connected (or just one) ?
My second question is : how much memory is needed if I want to use tomcat
with many users (500, 1000,...) ?

I already read in the forum Tomcat don't manage the memory, it is the
JVM... so why the jvm use so many processes ?






--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: TOMCAT memory usage : how to manage and benchmark ?

Posted by Bojan Smojver <bo...@rexursive.com>.
On Tue, 2002-10-29 at 00:10, Patrice.Boucher@groupe-asten.fr wrote:
> Hello,
> 
> I have tomcat 4.1.10 on a red hat Linux server 7.3 with the j2sdk141,
> 
> When I start the tomcat4 service, all is OK and the tomcat server run.
> 
> BUT, when I look the memory usage (with TOP utility), I have this result :
> 
>  11:31am  up 12 days,  2:18,  2 users,  load average: 0,00, 0,00, 0,00
> 90 processes: 87 sleeping, 3 running, 0 zombie, 0 stopped
> CPU states:  0,0% user,  0,5% system,  0,0% nice, 99,4% idle
> Mem:   514340K av,  479748K used,   34592K free,       0K shrd,   75716K
> buff
> Swap: 1048120K av,   35016K used, 1013104K free                  216648K
> cached
> 
>   PID USER     PRI  NI  SIZE  RSS SHARE STAT %CPU %MEM   TIME COMMAND
> 19954 tomcat4   25   0 33584  32M 10464 S     0,0  6,5   0:05 java
> 19957 tomcat4   15   0 33584  32M 10464 S     0,0  6,5   0:00 java
> 19958 tomcat4   15   0 33584  32M 10464 S     0,0  6,5   0:00 java
> 19959 tomcat4   15   0 33584  32M 10464 S     0,0  6,5   0:00 java
> 19960 tomcat4   15   0 33584  32M 10464 S     0,0  6,5   0:00 java
> 19961 tomcat4   15   0 33584  32M 10464 R     0,0  6,5   0:00 java
> 19962 tomcat4   20   0 33584  32M 10464 S     0,0  6,5   0:00 java
> 19963 tomcat4   16   0 33584  32M 10464 S     0,0  6,5   0:00 java
> 19964 tomcat4   16   0 33584  32M 10464 S     0,0  6,5   0:01 java
> 19966 tomcat4   15   0 33584  32M 10464 S     0,0  6,5   0:00 java
> 19967 tomcat4   15   0 33584  32M 10464 S     0,0  6,5   0:00 java
> 19968 tomcat4   15   0 33584  32M 10464 S     0,0  6,5   0:00 java
> 19969 tomcat4   15   0 33584  32M 10464 S     0,0  6,5   0:00 java
> 19970 tomcat4   15   0 33584  32M 10464 S     0,0  6,5   0:00 java
> 19971 tomcat4   15   0 33584  32M 10464 S     0,0  6,5   0:00 java
> 19972 tomcat4   15   0 33584  32M 10464 S     0,0  6,5   0:00 java
> 19973 tomcat4   15   0 33584  32M 10464 S     0,0  6,5   0:00 java
> 
> So,
> 
> My first question is : why tomcat use all the memory while there is no
> users connected (or just one) ?

Ah well, it's Java, that's why. There is a lot of side stuff going on in
a JVM that requires heaps (no pun intended) memory (i.e. you have to pay
for having strong runtime typing, no buffer overflows, run anywhere...).

> My second question is : how much memory is needed if I want to use tomcat
> with many users (500, 1000,...) ?

Huh, depends on what your applications do, really. For so many
concurrent users Tomcat will create separate threads, which means
separate local storage for all of them. Then there is the garbage
collection algorithm, which is usually "lazy", so more then absolutely
necessary will be allocated etc.

> I already read in the forum Tomcat don't manage the memory, it is the
> JVM... so why the jvm use so many processes ?

This is configurable in server.xml, I think. However, if you under
configure it, some clients may be left out.

Bojan


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [OT]Re: TOMCAT memory usage : how to manage and benchmark ?

Posted by Pier Fumagalli <pi...@betaversion.org>.
"micael" <ca...@harbornet.com> wrote:

> What operating system do you prefer, Pier?

We use Solaris both for Intel and Sun platforms... First reason being is
that we _know_ how that OS works, it's much more tuneable on live systems,
and much easier to configure when you know what you're doing...

Especially relating to Java, Solaris 8 was our platform of choice because of
threading support. Linux threads behave like processes (you see them in "ps"
for instance), that said it doesn't only have a "visual" disadvantage (that
same output can be generated on Solaris with "ps -AfL"), but also a
practical one... Limits and signals...

First of all, threads-as-processes are vulnerable to signals, and therefore,
given a bug in the VM (let's say a SEGV), what _can_ happen that only that
process dies (instead of the whole JVM set of processes), I've seen that
happening. Good point about that is that your Tomcat is going to be up, bad
point about that is that it's going to really mess up the JVM internals
(that's why Thread.kill() has been deprecated, and plus other random
reasons). Short story, threads-as-processes are much weaker than
threads-as-threads because of their behaviour towards the OS kernel...

Second point about Solaris 8 is the _two_ different configurations of
threads you can have... One is the default one, and works, but in some cases
(fixed number of threads, usually pooled, yadayadayada) a nice thing such as
"LWP" threads (used by pre-binding the /usr/lib/lwp/libthread.so in Java)
can come _really_ handy and delivers a _lot_ more performances... (this
helps a _lot_ also with Apache 2.0/worker).

Third reason, limits... In case of highly loaded environments, the kernel
will stop creating processes (and therefore threads under Linux) once the
process limit is reached, threads-as-threads don't suffer from that because
they are "nested" within their process scope, and the limit is _much_
higher.

File descriptor limits, memory limits, swapping, and so on, come for free
for us using Solaris, and it's _so_easy_ to tweak your network parameters on
live systems by tweaking the kernel with NDD (file descriptors are in
CLOSE_WAIT, no problem, set an NDD variable, and you're done)...

Plus, what the heck, Solaris 8 minimal install is probably 20 packages and
100 Mb for both 32 and 64 bits, while if you install RedHat, you can never
get below 400 Mb! :-) I love my disk space, and less code, less chances for
a bug, right??? :-)

It works for us, it has been working for ages, and we actually replaced all
our old Linux/x86 installations with Solaris8/x86.

That's production... For development, _of_course_ I use MacOS/X 10.2.2 which
is by far the best desktop on the planet... I've had a short test with an
X-Serve and load, performed allright (far better than a same-price Dell
box), but it went nowhere because at the same time we "inherited" a lot more
Sun Hardware for "free" (roughly! :-) so, we decided that we wanted to reuse
all those nice UltraSparc machines! :-)

    Pier


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


[OT]Re: TOMCAT memory usage : how to manage and benchmark ?

Posted by micael <ca...@harbornet.com>.
What operating system do you prefer, Pier?

At 01:31 PM 10/28/2002 +0000, you wrote:
>"Patrice.Boucher@groupe-asten.fr" <Pa...@groupe-asten.fr> wrote:
>
> > So,
> >
> > My first question is : why tomcat use all the memory while there is no
> > users connected (or just one) ?
>
>The JVM allocates chunks of memory (see the -Xmx and -Xms flags by invoking
>"java -X") and manages them... So, one user, 100 users, same thing...
>
> > My second question is : how much memory is needed if I want to use tomcat
> > with many users (500, 1000,...) ?
>
>On a 5 millions hits/day server (not running Tomcat, another servlet
>container since Tomcat doesn't work for us), we have the VM starting with 1
>Gigs of RAM ("java -server -Xmx 1024m -Xms 1024m ...") but we use half of it
>(roughly) to cache data from the DB...
>
> > I already read in the forum Tomcat don't manage the memory, it is the
> > JVM... so why the jvm use so many processes ?
>
>Those are _not_ processes, they are threads... Use a decent operating system
>that supports them nicely (not Linux) and you'll see the difference (how
>many times do I have to repeat this?)... Linux sucks :-(
>
>     Pier
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>

Micael

-------------------------------------------------------

This electronic mail  transmission and any accompanying documents contain 
information belonging to the sender which may be confidential and legally 
privileged.  This information is intended only for the use of the 
individual or entity to whom this electronic mail transmission was sent as 
indicated above. If you are not the intended recipient, any disclosure, 
copying, distribution, or action taken in reliance on the contents of the 
information contained in this transmission is strictly prohibited.  If you 
have received this transmission in error, please delete the message.  Thank you 



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: TOMCAT memory usage : how to manage and benchmark ?

Posted by Henri Gomez <hg...@apache.org>.
Pier Fumagalli wrote:
> "Henri Gomez" <hg...@apache.org> wrote:
> 
> 
>>>On Linux threads are +/- process and are really cheap to create, so it's
>>>should be a problem.
>>
>>Read, it shouldn't be a problem ....
> 
> 
> It is a problem because every time someone does a PS goes _nuts_ about the
> number of JVM processes... While at the end they are just threads... I
> believe I replied to this question at least 200 times in the past 5 years,
> and _still_ I see people asking...

Yes, I agree that seeing many entries with ps isn't correct but only 
Linux newbie have problem with it ;)

> And try to do a little piece of code creating 1000 threads on Linux and on
> Windows 2k... Just to see which one is faster (and I believe we _all_ agree
> that Windows sucks!)

It's a known case, even without doing the test I know that W2K will be 
faster to create thread. There is excellent documentation on Linux 
kernel on IBM alphaworks site and they show cases where Linux or W2K
implementations are better.

> :-) Anyhow, the old battle on why Linux sucks is over... Works for you,
> well, use it! :-)

Thanks, it works great for me on ia32 boxes and even on iSeries LPAR 
(PPC) ;)

>     Pier (MacOS/X rocks!)

Pier you know I'm allready convinced that MacOS/X rocks !

The question is why Apple didn't help OpenSource developpers to
switch their primary devel box from Linux ia32 to MacOS/X by making
affordable hardware .....




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: TOMCAT memory usage : how to manage and benchmark ?

Posted by Pier Fumagalli <pi...@betaversion.org>.
"Henri Gomez" <hg...@apache.org> wrote:

>> On Linux threads are +/- process and are really cheap to create, so it's
>> should be a problem.
> 
> Read, it shouldn't be a problem ....

It is a problem because every time someone does a PS goes _nuts_ about the
number of JVM processes... While at the end they are just threads... I
believe I replied to this question at least 200 times in the past 5 years,
and _still_ I see people asking...

And try to do a little piece of code creating 1000 threads on Linux and on
Windows 2k... Just to see which one is faster (and I believe we _all_ agree
that Windows sucks!)

:-) Anyhow, the old battle on why Linux sucks is over... Works for you,
well, use it! :-)

    Pier (MacOS/X rocks!)


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: TOMCAT memory usage : how to manage and benchmark ?

Posted by Henri Gomez <hg...@apache.org>.
> On Linux threads are +/- process and are really cheap to create, so it's
> should be a problem.

Read, it shouldn't be a problem ....




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: TOMCAT memory usage : how to manage and benchmark ?

Posted by Henri Gomez <hg...@apache.org>.
Pier Fumagalli wrote:
> "Patrice.Boucher@groupe-asten.fr" <Pa...@groupe-asten.fr> wrote:
> 
> 
>>So,
>>
>>My first question is : why tomcat use all the memory while there is no
>>users connected (or just one) ?

You should first see if your application is not eating memory.

>>My second question is : how much memory is needed if I want to use tomcat
>>with many users (500, 1000,...) ?

The question should be 'how many concurrents users' ?

> On a 5 millions hits/day server (not running Tomcat, another servlet
> container since Tomcat doesn't work for us), we have the VM starting with 1
> Gigs of RAM ("java -server -Xmx 1024m -Xms 1024m ...") but we use half of it
> (roughly) to cache data from the DB...
> 
> 
>>I already read in the forum Tomcat don't manage the memory, it is the
>>JVM... so why the jvm use so many processes ?

Also you could have many threads if you're using ajp13 connectivity
since there is one thread by connection with server.

> Those are _not_ processes, they are threads... Use a decent operating system
> that supports them nicely (not Linux) and you'll see the difference (how
> many times do I have to repeat this?)... Linux sucks :-(

On Linux threads are +/- process and are really cheap to create, so it's
should be a problem.

And if you have problem handling load with one Linux boxes, just use 
more Linux boxes and use jk load-balancing to spray the load.

I never find Linux to suck, it's really depend on which architecture
it run, and what you want to do with it. You could quickly start a
small tomcat handling 50 concurrents users on recent ia32 boxes, 
multiply the number of boxes when the load increase, and use software
load-balancing/fault-tolerance features of JK to make the tomcat/linux
farm works well better than high-end (and pricy Unix workstations).

With a very good performance/buck ratio ;)




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: TOMCAT memory usage : how to manage and benchmark ?

Posted by Bojan Smojver <bo...@rexursive.com>.
On Tue, 2002-10-29 at 20:15, jean-frederic clere wrote:

> The Linux threads implementation is _bad_ but that does not mean that
> the whole thing bad.

I was just teasing. Anyway, have a look at this:

http://marc.theaimsgroup.com/?l=linux-kernel&m=103269598000900&w=2

and this:

http://www-124.ibm.com/developerworks/oss/pthreads/

The first link is the future (2.6 or 3.0), the second is now.

> For the Fun. The kernel threads appair also in ps but I have not (yet)
> tried to kill one ;-)

There are known problems with POSIX compliance in the "stock" threads
(this includes signal delivery and other problems).

Bojan


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: TOMCAT memory usage : how to manage and benchmark ?

Posted by jean-frederic clere <jf...@fujitsu-siemens.com>.
Pier Fumagalli wrote:
> "jean-frederic clere" <jf...@fujitsu-siemens.com> wrote:
> 
> 
>>The Linux threads implementation is _bad_ but that does not mean that the
>>whole thing bad.
> 
> 
> That's why I said "works for you? Good"... For our setup we _need_
> threads...

So the problem is a little different: you need a JVM that uses the NGPT threads.

> 
> 
>>For the Fun. The kernel threads appair also in ps but I have not (yet) tried
>>to kill one ;-)
> 
> 
> It can provide hours of entertainment... Last time I tried it was _so_
> wicked! :-)
> 
>     Pier
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: TOMCAT memory usage : how to manage and benchmark ?

Posted by Pier Fumagalli <pi...@betaversion.org>.
"jean-frederic clere" <jf...@fujitsu-siemens.com> wrote:

> The Linux threads implementation is _bad_ but that does not mean that the
> whole thing bad.

That's why I said "works for you? Good"... For our setup we _need_
threads...

> For the Fun. The kernel threads appair also in ps but I have not (yet) tried
> to kill one ;-)

It can provide hours of entertainment... Last time I tried it was _so_
wicked! :-)

    Pier


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: TOMCAT memory usage : how to manage and benchmark ?

Posted by jean-frederic clere <jf...@fujitsu-siemens.com>.
Pier Fumagalli wrote:
> On 28/10/02 22:40, "Bojan Smojver" <bo...@rexursive.com> wrote:
> 
> 
>>On Tue, 2002-10-29 at 00:31, Pier Fumagalli wrote:
>>
>>
>>>Those are _not_ processes, they are threads... Use a decent operating system
>>>that supports them nicely (not Linux) and you'll see the difference (how
>>>many times do I have to repeat this?)... Linux sucks :-(
>>
>>Ha, ha... Keep dreaming Pier ;-)
> 
> 
> Works for you? Good! Doesn't for me! :-)

The Linux threads implementation is _bad_ but that does not mean that the whole 
thing bad.

For the Fun. The kernel threads appair also in ps but I have not (yet) tried to 
kill one ;-)

> 
>     Pier
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: TOMCAT memory usage : how to manage and benchmark ?

Posted by Pier Fumagalli <pi...@betaversion.org>.
On 28/10/02 22:40, "Bojan Smojver" <bo...@rexursive.com> wrote:

> On Tue, 2002-10-29 at 00:31, Pier Fumagalli wrote:
> 
>> Those are _not_ processes, they are threads... Use a decent operating system
>> that supports them nicely (not Linux) and you'll see the difference (how
>> many times do I have to repeat this?)... Linux sucks :-(
> 
> Ha, ha... Keep dreaming Pier ;-)

Works for you? Good! Doesn't for me! :-)

    Pier


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: TOMCAT memory usage : how to manage and benchmark ?

Posted by Bojan Smojver <bo...@rexursive.com>.
On Tue, 2002-10-29 at 00:31, Pier Fumagalli wrote:

> Those are _not_ processes, they are threads... Use a decent operating system
> that supports them nicely (not Linux) and you'll see the difference (how
> many times do I have to repeat this?)... Linux sucks :-(

Ha, ha... Keep dreaming Pier ;-)

Bojan


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: TOMCAT memory usage : how to manage and benchmark ?

Posted by Pier Fumagalli <pi...@betaversion.org>.
"Patrice.Boucher@groupe-asten.fr" <Pa...@groupe-asten.fr> wrote:

> So,
> 
> My first question is : why tomcat use all the memory while there is no
> users connected (or just one) ?

The JVM allocates chunks of memory (see the -Xmx and -Xms flags by invoking
"java -X") and manages them... So, one user, 100 users, same thing...

> My second question is : how much memory is needed if I want to use tomcat
> with many users (500, 1000,...) ?

On a 5 millions hits/day server (not running Tomcat, another servlet
container since Tomcat doesn't work for us), we have the VM starting with 1
Gigs of RAM ("java -server -Xmx 1024m -Xms 1024m ...") but we use half of it
(roughly) to cache data from the DB...

> I already read in the forum Tomcat don't manage the memory, it is the
> JVM... so why the jvm use so many processes ?

Those are _not_ processes, they are threads... Use a decent operating system
that supports them nicely (not Linux) and you'll see the difference (how
many times do I have to repeat this?)... Linux sucks :-(

    Pier


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>