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 ContentIf you enjoyed this post, make sure you subscribe to the RSS feed!



catalina.sh does not exist in the tomcat/conf/ directory. I have version 6.
If you are on Windows it is the “Catalina.bat” file, else let me know on what OS you are working on.
I am on Windows but I have the Tomcat “service” installation that starts up with Windows. The only two catalina files are:
catalina.policy
catalina.properties
I see, then the configuration is done via the services. Head over to http://tomcat.apache.org/tomcat-6.0-doc/windows-service-howto.html in that document they describe how to set parameters for the service configuration.
Thanks - I realize that you can just right click on the Tomcat 6 tray icon, click on the Java tab and plug in the three parameters there.
Thanks!
Sorry, when you right click, click the “configure” option first. Then you will see the java tab.
Great, thank you for the information for all Windows users.