You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Peter Sparkes <pe...@didm.co.uk> on 2007/08/04 08:16:45 UTC

Memory usage with multiple instances of tomcat

Hi,

I followed the "Tomcat with 8 GB memory" thread but did not find the 
answer to the following question:

I am setting up a Linux server with 8 GB memory which will be running 3 
instances of tomcat 5,5; when I allocate memory to java, say 2GB:

1. Does each tomcat instance use a separate 2 GB of memory, ie the 3 
instance use 6 GB between them ?
2. or do they potentially share they same memory?

In other words with the 6GB I want to share between the 3 separate 
Tomcat instances do I allocate the whole 6GB to Java or 2GB

Thank you

Peter Sparkes

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Memory usage with multiple instances of tomcat

Posted by Peter Sparkes <pe...@didm.co.uk>.
Thank you Chuck and Chris for your help and advice. I will definitely be 
reading your refs Chris

Regards
Peter
>   


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Memory usage with multiple instances of tomcat

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Peter,

> 1. Does each tomcat instance use a separate 2 GB of memory, ie the 3
> instance use 6 GB between them ?

Each instance gets a separate, 2GB heap space.

> 2. or do they potentially share they same memory?

Since Java 1.5, "shared archive" capability is available on Sun's JVM.
This basically means that the core JVM stuff can be memory-mapped and
thus shared between processes, so you actually get a benefit when you
run multiple simultaneous JVMs.

See:
http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html#vm_classdatashare
http://java.sun.com/j2se/1.5.0/docs/guide/vm/class-data-sharing.html

These pages cover this capability if you re interested in reading all
about it.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGt1nW9CaO5/Lv0PARAlFHAJ4q/MBMWrYMUBJTeu3/RPyzU1b1AQCfe8SJ
AMWfHzrgP0dAKeifLPxQ4Bw=
=5Dw/
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Memory usage with multiple instances of tomcat

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Peter Sparkes [mailto:peter@didm.co.uk] 
> Subject: Re: Memory usage with multiple instances of tomcat
> 
> The commands -Xms3g -Xmx3g will set the min/max heap to
> 3 GB, please how do I set the RAM for each instance of
> Tomcat5.5 to 2 GB

You can't set the amount of RAM for any process - the OS decides which
processes get how much RAM out of the total available.  Unfortunately,
Linux isn't particularly good at optimizing paging, so you're best to
keep the aggregate of virtual space allocations under the total RAM.
With three instances of Tomcat running, each with 3 GB heaps, you run
the risk of excessive paging if all the heaps get close to full at the
same time.  You might want to reduce the -Xms and -Xmx settings to
something like 2512m.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Memory usage with multiple instances of tomcat

Posted by Peter Sparkes <pe...@didm.co.uk>.
Thanks Chuck,

I am using a 64-bit versions of the OS and JVM and I was confusing 
virtual memory with RAM.

I have 8 GB of RAM and a 80 GB disc.

The commands -Xms3g -Xmx3g will set the min/max heap to 3 GB,please how 
do I set the RAM for each instance of Tomcat5.5 to 2 GB

Regards

Peter
>> From: Peter Sparkes [mailto:peter@didm.co.uk] 
>> Subject: Memory usage with multiple instances of tomcat
>>
>> 1. Does each tomcat instance use a separate 2 GB of memory, ie the 3 
>> instance use 6 GB between them ?
>> 2. or do they potentially share they same memory?
>>     
>
> Don't confuse virtual memory with RAM.  The heap allocations are
> virtual, so there is no physical relationship with the amount of RAM you
> have.  (There are performance considerations, of course, in that if you
> significantly oversubscribe RAM, you may suffer from excessive paging.)
>
> One thing you've failed to mention is whether you're using 32- or 64-bit
> versions of the OS and JVM.  If 32-bit, then process virtual space is
> typically limited to 2 GB, and the heap, code, and supporting libraries
> must fit within that - you won't be able to allocate all 2 GB to the
> heap.  If you're running a 64-bit environment, the sky's the limit
> (almost), and you could make each heap 256 GB, even with only 8 GB of
> RAM (not recommended, due to aforementioned paging concerns).
>
> Since each Tomcat runs as a separate process, there is no active sharing
> of either heap or code across instances.  However, if you're running a
> client version of a current HotSpot JVM, there is some sharing of loaded
> classes in the PermGen (other than static fields), primarily to reduce
> startup time.  You can see the shared amount in the Memory tab of
> JConsole.
>
> There is not currently any sharing in the server version of the HotSpot
> JVM.
>
>  - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail
> and its attachments from all computers.
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
>   


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Memory usage with multiple instances of tomcat

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Peter Sparkes [mailto:peter@didm.co.uk] 
> Subject: Memory usage with multiple instances of tomcat
> 
> 1. Does each tomcat instance use a separate 2 GB of memory, ie the 3 
> instance use 6 GB between them ?
> 2. or do they potentially share they same memory?

Don't confuse virtual memory with RAM.  The heap allocations are
virtual, so there is no physical relationship with the amount of RAM you
have.  (There are performance considerations, of course, in that if you
significantly oversubscribe RAM, you may suffer from excessive paging.)

One thing you've failed to mention is whether you're using 32- or 64-bit
versions of the OS and JVM.  If 32-bit, then process virtual space is
typically limited to 2 GB, and the heap, code, and supporting libraries
must fit within that - you won't be able to allocate all 2 GB to the
heap.  If you're running a 64-bit environment, the sky's the limit
(almost), and you could make each heap 256 GB, even with only 8 GB of
RAM (not recommended, due to aforementioned paging concerns).

Since each Tomcat runs as a separate process, there is no active sharing
of either heap or code across instances.  However, if you're running a
client version of a current HotSpot JVM, there is some sharing of loaded
classes in the PermGen (other than static fields), primarily to reduce
startup time.  You can see the shared amount in the Memory tab of
JConsole.

There is not currently any sharing in the server version of the HotSpot
JVM.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Memory usage with multiple instances of tomcat

Posted by Peter Sparkes <pe...@didm.co.uk>.
Thanks Adrian

Regards

Peter
> You'll need to allocate 2GB to each Tomcat instance. As long as you 
> use the standard Tomcat startup scripts each Tomcat instance will run 
> in a separate JVM (you'd have to be pretty deliberate about making it 
> run any other way).
>
> Regards,
>
> Adrian Sutton
> http://www.symphonious.net
>
>
>
> On 04/08/2007, at 4:16 PM, Peter Sparkes wrote:
>
>> Hi,
>>
>> I followed the "Tomcat with 8 GB memory" thread but did not find the 
>> answer to the following question:
>>
>> I am setting up a Linux server with 8 GB memory which will be running 
>> 3 instances of tomcat 5,5; when I allocate memory to java, say 2GB:
>>
>> 1. Does each tomcat instance use a separate 2 GB of memory, ie the 3 
>> instance use 6 GB between them ?
>> 2. or do they potentially share they same memory?
>>
>> In other words with the 6GB I want to share between the 3 separate 
>> Tomcat instances do I allocate the whole 6GB to Java or 2GB
>>
>> Thank you
>>
>> Peter Sparkes
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Memory usage with multiple instances of tomcat

Posted by Adrian Sutton <ad...@symphonious.net>.
You'll need to allocate 2GB to each Tomcat instance. As long as you  
use the standard Tomcat startup scripts each Tomcat instance will run  
in a separate JVM (you'd have to be pretty deliberate about making it  
run any other way).

Regards,

Adrian Sutton
http://www.symphonious.net



On 04/08/2007, at 4:16 PM, Peter Sparkes wrote:

> Hi,
>
> I followed the "Tomcat with 8 GB memory" thread but did not find  
> the answer to the following question:
>
> I am setting up a Linux server with 8 GB memory which will be  
> running 3 instances of tomcat 5,5; when I allocate memory to java,  
> say 2GB:
>
> 1. Does each tomcat instance use a separate 2 GB of memory, ie the  
> 3 instance use 6 GB between them ?
> 2. or do they potentially share they same memory?
>
> In other words with the 6GB I want to share between the 3 separate  
> Tomcat instances do I allocate the whole 6GB to Java or 2GB
>
> Thank you
>
> Peter Sparkes
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org