Forums Forums  |  Forums Sitemap

GlassFish or Tomcat: Which is Right for


If you value application performance, usability, and agility, take a closer look under the hood.

The CEO always has very simple questions for IT management. Why are customers complaining about the new online ordering system? Why is it taking eight months to roll out that new Web service? Why did my financial reporting app crash this morning?

What the CEO rarely asks IT management is which application server technology the company is using. But in many cases, that's the relevant question, because there is a direct connection between the app server used by development teams and the performance and agility of the company's applications.

More specifically, the Web container technology employed in the app server can be a determining factor in application quality and developer productivity. With the right Web container technology your development teams get more done and your apps are delivered faster and perform better. The wrong choice can be a source of heartburn — now and later.

So if applications are your business, it pays to take a closer look at the inner workings of the app server, the Web container technology, and their impact on development teams. This article compares two of the most popular open source options: GlassFish and Tomcat.

Two popular options — many important differences

GlassFish is the open source application server delivered by the GlassFish Community, which was launched by Sun in 2005 and has proven to be extremely popular among developers. There are two prevalent versions today: GlassFish v2, and the newly released Glassfish v3 Prelude. Nearly 9,000,000 copies of GlassFish v2 have been downloaded to date, with 300,000 product registrations in 2009 alone. GlassFish v3 Prelude offers new features and enhancements. It is an excellent platform for deploying rich Internet applications backed by Java or dynamic languages such as jruby.

The Tomcat app server was launched by Apache by a group that included Sun and JServ developers; the initial code drop came from Sun. Tomcat was critical to the early adoption of server-side Java, was available under an open source license, and contributed to the popularity of open source software within large enterprises.

In general, applications that run on Tomcat will also run unchanged on GlassFish. However, there are important differences that impact application performance, scalability, usability, and developer productivity.

To understand these differences, it is important to look at the underlying Web container technology. The Web container is the part of an app server that manages servlets, JavaServer Pages (JSPs), and other Web-tier components.

While GlassFish is a collection of Java EE containers, one of which is a Web container, Tomcat is just a Web container. This crucial difference leads to some major advantages for GlassFish:

  • Easier migration path. With GlassFish v2 there is a clear, straightforward way to take advantage of technologies such as Enterprise Java Beans (EJBs), the Java Persistence API (JPA), Java Message Service (JMS), and other capabilities. With Tomcat, these technologies must be added piecemeal, one at a time. It is the developer's responsibility to implement the capabilities and make sure it all works — and works together.
  • Out-of-the-box support for clustering and failover. GlassFish v2 can provide clustering and sophisticated high-availability capabilities enabling applications to meet stringent, enterprise-class service-level agreements (SLAs). GlassFish v3 Prelude can support clustering via a load balancer but does not yet have a clustering profile.
  • Superior administration/monitoring. GlassFish v2 and v3 Prelude both support centralized administration through a management console and via a Command Line Interface (CLI). GlassFish v2 provides Call flow Monitoring, which enables an application developer or server administrator to determine where an application is spending most of its time. This feature will also be available in GlassFish v3. In addition, third-party vendors can make their software available via the GlassFish Update Center for easy setup on GlassFish. With Tomcat, new software must be configured in a piecemeal fashion. Update Center also provides early access to newer versions of technologies such as EJB 3.1, which allows for bundling EJB in a WAR rather than having to package the application as an EAR file.
  • Support for scripting languages. GlassFish supports or soon will support Ruby/JRuby, Python/Jython, Groovy, PHP, JavaScript/Phobos, Scala, and other languages.

The nitty gritty: additional Web container differences

Beyond the general advantages mentioned above, GlassFish further differentiates itself from Tomcat in its Web container capabilities. Just a few examples:

  • The ability to retain sessions across application redeployments (v3 Prelude) is a time saver for developers creating Java Web applications.
  • GlassFish v2 and v3 Prelude provide support for dynamic reconfiguration of virtual servers and HTTP Listeners, with no server restart required. With Tomcat, if you make a change to a resource pool you typically have to restart the app server.
  • High-performance, highly scalable Grizzly Framework in v2 and v3 Prelude improves request/response throughput. The lower layers of the Web Tier in GlassFish are implemented through the Grizzly Framework. The framework is written in Java taking advantage of the NIO APIs (scalable network and file I/O) to provide scalability and is also highly customizable.
  • GlassFish v2 and v3 Prelude include various performance optimizations, such as "flattened valve invocation," a modification to the valve architecture that streamlines how each valve gets called, resulting in smaller stack depth and better performance. GlassFish v3 Prelude can support Tomcat-style valves as well.