Running Tomcat in production environments

Koekiebox picture Koekiebox · Nov 15, 2010 · Viewed 16.5k times · Source

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?

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

Our system/s have around 100 to 400 users.

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

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

Thanks.

Answer

Daniel Baktiar picture Daniel Baktiar · Feb 24, 2011

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.