aspose file tools*
The moose likes Tomcat and the fly likes How much Heap Size is enough for Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "How much Heap Size is enough for Tomcat" Watch "How much Heap Size is enough for Tomcat" New topic
Author

How much Heap Size is enough for Tomcat

Khosrow Moossavi
Greenhorn

Joined: Aug 08, 2005
Posts: 26
Hello Guys,

We're currently having a Private Tomcat (version 6.0.16) hosting package, which gives us plenty of control over server, tomcat. So basically we're happy. But after deploying almost each and every new Java Application to Tomcat, we have to purchase more Heap size, which is ok and reasonable on the other hand.

The question is How much Heap Memory Size per application we need? I know that the more, the better, but what is the minimum of it?
Applications are generally a typical struts/spring/hibernate integration. The current is 32 MB starting, 128 MB maximum, and 4 applications work perfectly fine, but for recently deployed 5th and 6th, sweet little PermGen is there, slap me in the face!

If there are more things I should tell in order for "an" answer or a better one, please tell me to find that out. I don't think of anything else right now.

Regards,
Khosrow.


SCJP and SCWCD are going to be installed here.
Hongli Li
Ranch Hand

Joined: Oct 29, 2006
Posts: 124
before you deployed your application to tomcat, have you done any load tests? a good load test should give you some good estimate of memory usage.


Do you know why this cup is useful? Because it is empty.
Kees Jan Koster
JavaMonitor Support
Rancher

Joined: Mar 31, 2009
Posts: 251
    
    5
Dear Khosrow,

The answer to your question is: that depends.

Make sure you monitor your heap size and permgen sizes. These are not the same, by the way. A bigger heap does not mean you have a bigger permgen.

Kees Jan


Java-monitor, JVM monitoring made easy <- right here on Java Ranch
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Khosrow Moossavi wrote:The question is How much Heap Memory Size per application we need? I know that the more, the better, but what is the minimum of it?


"Too Big to Fail" doesn't work for heap memory size. Garbage collection could slow down the application, while cleaning large heap. There are plenty of information on web regarding JVM tuning. Keep in mind that you have to find guidelines for your particular JVM flavor.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

Garbage collection could slow down the application, while cleaning large heap.


Actually most JVMs these days run an incremental garbage collector instead of a "wait till it's full and then shut everything down while we GC".

But merely adding more resource demands to the server is enough to slow it down anyway. Then again, what use is an idle server?


Customer surveys are for companies who didn't pay proper attention to begin with.
Khosrow Moossavi
Greenhorn

Joined: Aug 08, 2005
Posts: 26
Thank you guys for your answers.

Well I have not considering monitoring that much, because we were good both in Development and Deployment environment. But after this, I've installed Java-monitor and here is the Result about Heap, PermGen and GC:


java.lang:type=MemoryPool, name=PS Perm Gen
    Usage.used: 107 MiB and 588 KiB
    Usage.committed: 114 MiB and 256 KiB
    Usage.max: 128 MiB


java.lang:type=Memory
    NonHeapMemoryUsage.committed: 120 MiB and 384 KiB
    HeapMemoryUsage.used: 87 MiB and 667 KiB
    ObjectPendingFinalizationCount: 0
    NonHeapMemoryUsage.used: 113 MiB and 119 KiB
    NonHeapMemoryUsage.max: 176 MiB
    HeapMemoryUsage.max: 113 MiB and 832 KiB
    HeapMemoryUsage.committed: 109 MiB and 512 KiB


java.lang:type=GarbageCollector,name=PS MarkSweep
    CollectionCount: 4
    CollectionTime: 1 second and 426 milliseconds


java.lang:type=GarbageCollector,name=PS Scavenge
    CollectionCount: 77
    CollectionTime: 652 milliseconds +5


Well, to be honest I didn't google for these terms yet. But are we good or anything seems not working all right?
What Monitor Application should I use? There are plenty out there and I couldn't decide what is good, so I went for the one that is on Kees Jan's signature.

Regards,
Khosrow.
Kees Jan Koster
JavaMonitor Support
Rancher

Joined: Mar 31, 2009
Posts: 251
    
    5
Dear Khosrow,

Welcome to Java-monitor. :-)

It is actually more useful to post the graphs, rather than the actual values. The graphs show how memory develops over time and the stats you posted are just a snapshot.

You will find a "post graph" button under each one. Please post the heap memory graph on Java-monitor and I'll help you there. :-)

Kees Jan
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How much Heap Size is enough for Tomcat