Running Tomcat in production environments

100-400 user is a relative small deployment. I helped clients in deploying Tomcat solution with much much bigger registered user base (in the range of millions) or concurrent users. I do not even believe a cluster is needed for your deployment.

To cluster Tomcat server is pretty simple. Putting a load balancer in front of the Tomcat servers. Configure the Load balancer with session stickyness. And you will have a very nice Tomcat cluster. Some clients want session failover in case one Tomcat instance fails and user can be automatic route to a second instance without losing session data. I consider this to be over kill for your deployment. In reality, the downtime caused by regular maintenance will be much higher than system failure. I have Tomcat servers running for months and only need to bring in down for major code releases. But in case it is needed, there are open source package supporting session clustering.

Speaking of that, most J2EE application performance problem originated from the application itself rather the Tomcat server. Here are Top J2EE Application Performance Problems that I encountered the most when I trouble shoot my client system performance. Hope this help.


I am currently using Tomcat6 as a Web-Container on development and production.

I have heard that Tomcat is not the best performing Web-Container for production environments. Is this true?

Well, again it depends on how do you see it. Tomcat can perform very well, and it is used everywhere in the production, with largest user base. Some commercial application servers use Tomcat under the hood without even telling you.

Of course you should not compare Tomcat out-of-the-box performance to a well tuned web containers. Tomcat can be tuned for much better performance than it's out-of-the-box state. You can google: "tomcat production" for example and see how people managed it in real production and get a lot of advices, tips, etc.

Is Tomcat sufficient in terms of performance and memory management to use on production environments?

Yes, it is. When you need more, there are a lot of vendors that offers commercial version of Tomcat, including monitoring and instrumentation to help maintain your application in production.

Our system/s have around 100 to 400 users.

Tomcat can handle more than this for sure. Depends on the nature of your application/system, you may require more than one instance of Tomcat. In real production environment it will be wise to cluster your Tomcat.

For me its more about how the Web-App was written and the type of operations inside the Web-App.

Half truth.

I believe good architecture and framework will also save you a lot of time when you are about to cluster the Tomcat. So you need to have a general knowledge about how web container application works, how your framework handles things in clustered environment and how they are clustered, before deciding how you lay down your framework stack.

For example issues may arise from:

  • in memory caching in more than one JVM instances
  • session store (memory, database, file store) and its replication

Clustering Tomcat is not a trivial task, and laying down your framework improperly will make it difficult to incorporate clustered Tomcat later.

Even if performance is a problem on one Tomcat instance, is it possible to cluster Tomcat?

Yes, it is possible to cluster Tomcat. The way you design your application determines whether your application will be ready easily for clustering, or will be more complicated to cluster. This issue may not be specific to Tomcat, but to application servers in general.

Some issues you may need to consider:

  • what data you store in (HTTP) session
  • where to store the session
  • keep alive session
  • use web server application load balancing reverse proxy e.g. Apache Web Server + mod_proxy/mod_jk, nginx, Varnish
  • which Tomcat connectors to use (Blocking IO, NIO, APR)

There are some other issues, but I think those are you can start with.