CFML

Performance tips for Tomcat and Open BlueDragon

I get a lot of questions on this blog and a lot more per eMail on how to fine tune Tomcat and get it running together on Apache and other stuff. Since the release of Open BlueDragon, Tomcat is more apparent to a lot of CFML-Developers then ever.

I already posted an entry of how to get Tomcat running “behind” Apache and thus will focus here on the two configurations that helps the most.

Tomcat and memory

The number one issue I am seeing on the net is that a lot of users complain that Tomcat runs out of memory or pages are not being served properly. I have also seen a lot of posts where people are only posting snippets of codes but no real world examples of where to change values and how to (just read the FAQ about memory issues over at the official Tomcat site and you know what I mean). But actually it is so easy…

By default, Tomcat sets its own memory size at around 64MB which by far is not enough for web applications. You can set the “start size”, the “maximum size” and you also need to up the heap space. to find out the proper values for your platform you will need to issue the command “java -X” in the terminal. For MacOS X 10.5.2 these parameters are:

-Xms<size>  set initial Java heap size
-Xmx<size>  set maximum Java heap size
-Xss<size>   set java thread stack size

Once you know your parameters you should allocate about 80% of your available Ram to Tomcat.

Open up your “catalina.sh” file (in the Tomcat installation folder under “conf”) and add the following lines at the top of the file, but just underneath the comment section.

With the above settings I get the following Ram allocations under MacOS X.

Just about enough for any decent web application :-)

Default settings in web.xml

The web.xml is the document that defines default values for ALL Web applications loaded into each instance of Tomcat. As each application is deployed, this file is processed, followed by the “/WEB-INF/web.xml” deployment descriptor from your own applications.

By default, Tomcat sets the “reload” and the “development” parameters to “true”. The tricky thing is that these parameters can not be found anywhere as they are set by the server internally. Thus we need to ADD these two parameters and set them to “false”.

Open your web.xml file (in the Tomcat installation folder under “conf”) and add the two values to the “JSP” servlet container.

After you have done these two fundamental changes you should restart Tomcat. Watch how your applications behave and change the memory settings if needed.

Sphere: Related Content

If you enjoyed this post, make sure you subscribe to the RSS feed!

7 Comments

speak up

Add your comment below, or trackback from your own site.

Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*Required Fields