• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Advanced performance adjustments for Tomcat

 
Ranch Hand
Posts: 57
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everyone,

I'd like to find out if there is process that would allow for guaranteed performance tuneup for Tomcat server.

The only viable parameters I found to be useful to adjust are:
Initial memory pool size in MB
Maximum memory pool size in MB
Thread stack size in KB

I check the status here:
http://localhost/manager/status

And I'm trying to bite my way through this doc:
http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html

I found that playing with these parameters is resulting in changes in performance when I do load testing:

-Xms256m -Xmx1024m -XX:NewSize=128m -XX:MaxNewSize=128m -XX:SurvivorRatio

I actually never set Thread stack but this is what I found out about it:
Deep recursive algorithms can also lead to Out Of Memory problems. In this case, the only fixes are increasing the thread stack size (-Xss), or refactoring the algorithms to reduce the depth, or the local data size per call.
I believe that someone suggested 1024KB but I could not start the server with that size.

Any tips hints and suggestions would be greatly appreciated.

 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure what you mean by "guaranteed performance tuneup".
Tomcat's defaults, for the most part, are set for production. Most of the changes I make slow things down but make more friendly for production (reloadable, logging etc...).

The memory changes that you mentioned are less Tomcat specific and more JVM specific. If you want to learn how to tweak the JVM, you might want to try some google searches that don't include Tomcat.
This was my first find when I googled "Java JVM Tuning"

http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/tprf_tunejvm.html

Are you having a specific performance issue that you're trying to address?
 
Mat Banik
Ranch Hand
Posts: 57
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I run Spring app server and every time I reach 10000 active connections the server runs out of resources and requires reboot. I have been able to work around the issue by setting limits on the applications being run.
I don't know how to cross 1024 maximum memory limit. I can pup up the server with 16GB of ram and since it is on the cloud the processors would be no issue either but I don't know enough about tomcat or more precisely JVM to go start tuning this out.
There for I'm looking for some sources to start learning about it. Including spreading the View-Model processing on several Tomcat instances.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tomcat can be clustered.
There is good documentation on their site for this.
http://tomcat.apache.org

I've read that the 1024 M limit is due to 32 bit OSes can't give more than 1024 megs of contiguous blocks of ram to a single application and that JVMs require contiguous blocks. I don't know whether this a Windows OS thing or if it's an Intel chip thing.
If it's the latter, switching to Linux wouldn't help. The fix, I've read, is to upgrade to a 64bit system.

I'm hitting the 1024 ceiling myself. I'm looking at a couple options. One is to upgrade hardware to have a 64 bit system.
I'm also toying with the idea of taking some of the more memory intensive operations (PDF merging and creation, for example) and forking a new process for them. Tomcat give you the option to do this with JSP compilation.
 
Mat Banik
Ranch Hand
Posts: 57
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I run dev server on Windows 2003 32bit and production on CentOS 64bit. But I can't mess around with production too much. So I'm trying to pool some info first and develop trial and error plan.

I don't know how this:
http://tomcat.apache.org/tomcat-6.0-doc/cluster-howto.html

would work with Spring framework. I heard about Terracotta but I'm not sure how that would work since I haven't even seen clustered tomcat or spring yet.

I don't use much JSP. I'm running the front-end on sitemash and freemarker.
I would imagine there would be some problems with application context. I'm running most of the pages stateless but some are statefull and that could be a problem.
 
JavaMonitor Support
Posts: 251
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Matej,

It would help greatly if you posted the stack traces that you find in the logs before the reboots. Without those we do not know what resources Tomcat runs out of and tuning is pointless.

There are no "guaranteed performance tuneup" for any app server. It all depends on what you make that app server do.

Post stack traces.

Kees Jan
 
Mat Banik
Ranch Hand
Posts: 57
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The logs are standard vanilla stuff about Catalina not having enough memory.
I will install 64 bit system so I can test the JVM with more memory allocation.
Did anyone try to run tomcat with 16GB of ram on 64 bit system?
 
Kees Jan Koster
JavaMonitor Support
Posts: 251
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Matej,

Please note that there are a dozen or so forms of OOME's. Please post the message part of the exception, so we can see what happend precisely.

We routinely run with 6 GB heaps. No problem.

Kees Jan
 
Mat Banik
Ranch Hand
Posts: 57
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kees Jan,

I have no idea what OOME means. If you have link to at least one forum that is in your opinion good I would appreciate it.

Every-once in while I get java.lang.OutOfMemoryError: Java heap space.
I tweak the heap sizes around with garbage collector every time and it is good after that for a while. But there is only as much you can do on 32 bit JVM.

I'm trying to find out if I can run 64 bit CentOS with JVM (JDK 6.0) that is 64bit. But I fount out that it will be problem with intel processors. The AMD once seem to be the only processors that will work with 64bit JDK 6.0.

At this point it seems that I should open post on 64bit JDK.

Are you running it on your own server or do you have dedicated hosting or do you run on cloud space?

Mat
 
Kees Jan Koster
JavaMonitor Support
Posts: 251
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Matej,

OOME is short for OutOfMemoryError.

The Saloon on Javaranch is a great forum. Probably the best. I like http://java-monitor.com/forum/ too, but I am biased, since I operate that forum. ;-)

The error you posted confirms this is a heap space issue and not something else.

I run JDK 1.6 in 64-bit mode on both AMD and intel processors. It just works. I have my own hardware.

I would suggest you also make heap dumps and use profiling to try to reduce the memory footprint of your application. That will give you more time to buy hardware.

Kees Jan
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kees Jan Koster wrote:Dear Matej,

OOME is short for OutOfMemoryError.

The Saloon on Javaranch is a great forum. Probably the best. I like http://java-monitor.com/forum/ too, but I am biased, since I operate that forum. ;-)

The error you posted confirms this is a heap space issue and not something else.

I run JDK 1.6 in 64-bit mode on both AMD and intel processors. It just works. I have my own hardware.

I would suggest you also make heap dumps and use profiling to try to reduce the memory footprint of your application. That will give you more time to buy hardware.

Kees Jan



Gotta admit I was scratching my head about "OOME" myself. I have enough trouble with NPE.

Getting good stack info is critical. I lost nearly a month of my life on a, ahem, OOME that was only reproducible by allowing the system to run for 3-5 days. Turned out to be a "cache" that didn't understand that part of the difference between a cache and a bottomless pit is that a cache is expected to have a limit beyond which it starts discarding stuff.

The worst thing was, this "cache" was from a major vendor, who had even explicitly documented its lack of a discard mechanism. But not very well.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic