Learning GlassFish for Tomcat Users White Paper February 2009 Abstract There is a direct connection between the Web container technology used by developers and the performance and agility of applications. This paper demonstrates the alignments and differentiators between GlassFish and Tomcat, allowing Tomcat users to make an informed decision about which is right for their environment.
Table of Contents Executive Summary... 3 Overview: GlassFish and Tomcat... 3 GlassFish Web Container Advantages vs. Tomcat Web Container... 4 Usability/Productivity... 4 Reliability and Availability... 5 Security... 5 Performance and Scalability... 5 Web Container Feature Alignment: GlassFish and Tomcat... 6 Conclusion... 8 For More Information... 8
3 Executive Summary For Web 2.0 start-ups, application service providers, and ISVs offering dynamic Web based applications, the application is the business and the Web container technology used in the application server can impact business results. The Web container is the part of an app server that manages servlets, JavaServer Pages (JSPs), and other Web-tier components. Web container technology plays a vital role in determining the performance and adaptability of Web-tier software components, so there is a direct connection between the Web container technology used by developers and the performance and agility of applications. Sun asserts that the Web container features of GlassFish application server are far more extensible, modular, easy to use, and adaptable than those of Apache Tomcat while offering comparable performance. With support for clustering, persistence, messaging, and other key features that Tomcat lacks, as well as enterprise-class service and support from Sun and the backing of a large and thriving community, GlassFish is a superior alternative for those who wish to move beyond Web-tier application development. Overview: GlassFish and Tomcat GlassFish is the open source application server delivered by the GlassFish Community, which was originally launched by Sun in 2005. GlassFish v2 has notched nearly nine million downloads and 300,000 product registrations in 2008. The current version, GlassFish v3 Prelude, features an architecture that is modular by default, allows for rapid, iterative Java Web development, and supports dynamic languages. It is an excellent platform for deploying rich Internet applications backed by Java or dynamic languages such as jruby. Sun GlassFish Enterprise Server v2 is a commercially supported, Java Enterprise Edition (EE) 5 compatible offering. The commercial version adds an enterprise-quality app server to the options available to the open source community and builds on the foundation set by Sun Java System AppServer. Tomcat was started at Apache by a group that included Sun and JServ developers; the initial code drop came from Sun. It became the Reference Implementation (RI) for early versions of the Java Servlets and JSP specifications (the RI for the latest specs is GlassFish Server). 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 enterprise organizations. In general, applications that run on Tomcat will also run unchanged on GlassFish. However, there are important differences between Tomcat and GlassFish that impact application performance and scalability, usability, and developer productivity.
4 It is important to note that 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 creates some key advantages for using 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 Callflow 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. GlassFish Web Container Advantages vs. Tomcat Web Container In addition to the overarching advantages of GlassFish compared with Tomcat, there are additional differentiators between GlassFish Web container and Tomcat Web container capabilities. The list below summarizes just a few examples of the advantages. Usability/Productivity The GlassFish Update Center (available in v2 and v3 Prelude) offers developers point-and-click access to additional features that can extend the GlassFish Server. Examples include Open ESB for building loosely coupled applications, and Jersey (JA-RS 1.0) for building RESTful Web Services. The ability to retain sessions across application redeployments (v3 Prelude) is a time saver for developers creating Java Web applications
5 Alternate docroots at the virtual server and Web applications means Web applications no longer need to bundle resources as part of the Web app docroot; they may be shared by other Web applications. For example, common images such as icons no longer need to be packaged together, saving time and effort. Reliability and Availability 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. GlassFish supports fine-grained associations between virtual servers and HTTP Listeners. A virtual server will receive only those requests that were received on any of the HTTP listeners that were associated with it. This is extremely useful for virtual hosting where one could run multiple Web sites on the same physical server machine. This feature also helps with better hardware resource utilization as compared to running each site on a separate machine. GlassFish v3 Prelude provides superior Comet/AJA Push compared to Tomcat. With Tomcat the developer needs to write a lot of code to get the same Comet functionality provided by GlassFish. Centrally manage high-availability cluster and load balancer agent configuration (v2). Security With virtual server security realms (available in GlassFish v2 and v3 Prelude), you can specify security in a file realm, a database realm, an LDAP realm, etc. Security realms are specified in the domain s configuration and referenced by Web applications with authentication requirements deployed to the domain. It is also possible to reference security realms at the virtual server level, in which case the security realm applies to all Web applications deployed to the virtual server (a Web application may still override the security realm at the virtual server level with its own). This allows a virtual hosting company to enforce homogeneous security requirements for all the web applications hosted by it. GlassFish v2 supports Java Authentication and Authorization JSRs 115 & 196. Various 118N enhancements in GlassFish v2 and v3 Prelude allow for HTTP request encoding detection (configurable in sun-web.xml). Performance and Scalability Default Web module support in v3 Prelude improves performance and reduces start-up times compared with previous versions of GlassFish. High-performance, highly scalable Grizzly connector in v2 and v3 Prelude improves request/response throughput. The lower layers of the Web Tier in Glass- Fish are implemented through the Grizzly Framework (https://grizzly.dev.java.net).
6 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. GlassFish now supports JSR 199, the Java Compiler API, for JSP compilations. Preliminary performance measurements show an order of magnitude improvement in raw Javac compilation speed, and a 3.5x improvement in overall execution when running JSP TCK tests. Sun has performed extensive scalability testing to compare the NIO connectors of Tomcat and Glassfish. These tests use a simple servlet to minimize the time spent in the container and measure how many operations/second the various containers can support for increasing numbers of users. For example, at 16,000 users, our benchmark gives these results: GLASSFISH TOMCAT Ops/Second 6988.9 6615.3 Avg. resp time 0.242 0.358 Max resp time 1.519 3.693 90% resp time 0.6 0.75 Full details are available at: http://weblogs.java.net/blog/sdo/archive/2007/05/how_to_test_con.html Web Container Feature Alignment: GlassFish and Tomcat Compounding the advantages of GlassFish Server and GlassFish Web Container over Tomcat, the GlassFish Community has provided support for well-known features of Tomcat within GlassFish. The table below summarizes the Tomcat features that are provided by GlassFish and the additional GlassFish capabilities not currently provided by Tomcat.
7 Feature Tomcat GlassFish v2 GlassFish v3 Prelude Tomcat valves mod_jk support Webdav support CGI support Tomcat bug fixes Java EE certified Servlet 2.5, JSP 2.1 JSF 1.2 Metro Web Services stack (.NET interoperability) jmaki (AJA framework) Jersey/JA-RS 1.0 (RESTful Web Services) Sophisticated Admin console and CLI JM Node Agent and Cluster Management Upgrade Tool Application client container Java Webstart support JDBC Connection Pooling JTA/JTS J2EE Connector Architecture 1.5 Native jruby/rails deployment no need for servlet container Dynamic resizing of jruby Runtime Pool Rapid redeployment maintain session state on redeploy Update Center Verification tools Image Packaging System (IPS) tools Grizzly (Java NIO) Comet (HTTP Push) CORBA Modular architecture based on OSGi Embeddable Server Centralized admin of load balancer plug-in High availability In-memory compilation of JSPs Integration with Identity Manager, Access Manager, Registry Server, and Java Business Integration Superior admin support for clustering and load balancing
8 Conclusion At all levels, GlassFish is simply a better option than Tomcat for developers and companies that want to expand beyond Web-tier applications. GlassFish is a collection of Java EE containers, not just a Web container GlassFish is much more extensible and modular than Tomcat, and can be easily expanded as developers take advantage of capabilities such as messaging, clustering, failover, and session management, and use more features such as EJBs, JMS, JSR, and Web services. GlassFish supports many powerful Web container capabilities that Tomcat does not, and support many of the best-known Tomcat features. The choice of an app server is highly strategic for businesses, and GlassFish has proven to be a superior strategic option for developers of next-generation applications. For More Information For additional details about GlassFish, visit https://glassfish.dev.java.net/ To download GlassFish software, visit http://java.sun.com/javaee/downloads/index.jsp To join the GlassFish Community, visit https://glassfish.dev.java.net/public/devindex.html
Learning GlassFish for Tomcat Users 4150 Network Circle, Santa Clara, CA 95054 USA Phone 1-650-960-1300 or 1-800-555-9SUN (9786) Web sun.com 2008 All rights reserved. Sun, Sun Microsystems, the Sun logo, GlassFish, and Java are trademarks or registered trademarks of in the United States and other countries. Information subject to change without notice. Printed in USA 12/08 553556-0/#K