There is no doubt about it: Apache Tomcat is big topic. As the most widely used application server in the world, it has a ton of configuration options to suit all sorts of businesses. The Apache Software Foundation has done an exceptional job at setting up reasonable defaults, yet there always seems to be one more trick you can learn. Today, in a post by Apache Tomcat Release Manager and SpringSource engineer, Mark Thomas goes over four common mistakes he sees people on the Tomcat mailing lists and SpringSource support queues make.
Mistake 1: Global vs Application Context.xml
The first is understanding the difference between global and application context.xml files. Adding datasource to a single application in the application level context.xtm file is different than editing the global context.xml file as Thomas explains:
If you have 10 web applications, and create a new JNDI datasource with 50 connections to the database in the globalcontext.xml file, you have essentially created 10 JNDI datasources with a total of 500 connections to your database and have likely completely overwhelmed your database.
Mistake 2: Create a Single Datasource
When more than one application is sharing a datasource, configuring your datasource with a single resource link into the global context.xml file helps ensure that all applications share the same data source instead of creating copies.
Mistake 3: Optimizing Garbage Collection
Since we can’t always get what we want, sacrifice is usually in order. In order to achieve small GC pauses and a high throughout, you have to sacrifice and have a large heap. Run your application to steady state, and run garbage collection. This is the minimum heap size and you should set your max heap to 4 or 5 times that size.
Mistake 4: Developing and Deploying on Multiple Servlet Containers
For a variety of reasons, many organizations use a variety of application servers instead of just a single servlet container. To avoid cross-compatibility issues, set the system property for StrictServletCompliance. Please check out more information on StrictServletComplliance here.
For more details and background on each of these mistakes, and how you can avoid them, see the full post http://www.tomcatexpert.com/blog/2011/08/03/4-mistakes-avoid-apache-tomcat4 Mistakes to Avoid on Apache Tomcat from Mark Thomas.