Jetty vs Tomcat: A Comparative Analysis

来源:互联网 发布:万达电影网络院线 编辑:程序博客网 时间:2024/05/21 11:19

http://www.webtide.com/choose/jetty.jsp

Jetty vs Tomcat: A Comparative Analysis

prepared by Greg Wilkins - May, 2008

1. Introduction

Jetty and Tomcat are often cast as direct competitors. This paper is short comparison of the technical and non-technical aspects of these two open source servlet containers.

2. Technical Comparisons

2.0. Architecture

The view from 20,000 feet is that Tomcat and Jetty are rather similar, they are both java applications servers offering implementations of the 2.5 servlet specification with optional extras giving many JEE features.

However, on closer inspection, the architectures of the two servers differ greatly, mostly because each project as historically had a different focus:

Tomcat is first and foremost an application server. Its default incarnation is as software installed onto a system, into which one can install applications. Tomcat can be stripped down to be embedded or built up the be an full JEE server, but both are difficult exercises.Jetty is first and foremost a set of software components that offer HTTP and servlet services. Jetty can be invoked and installed as a stand alone application server or it can be easily embedded in an application or framework as a HTTP component, as a simple servlet engine, as a feature rich servlet engine or as part of a full JEE environment.

It is the flexible component based architecture of Jetty that allows it to be flexibly deployed and integrated in a diverse range of instances:

  • From mobile phones to large clusters of big iron servers
  • In software frameworks and tools: OSGi Equinox, OSGi Felix, Spring, Plexus, Cocoon, Tapestry, Maven, Continuum, Fisheye, Grails, JRuby, Xbean, etc.
  • In JEE application servers: Geronimo, Jboss, Sybase EAServer, JOnAS and Glassfish
  • Embedded in applications, products and services from IBM, HP, Cisco, BEA, Yahoo, Eclipse (see http://docs.codehaus.org/display/JETTY/Jetty+Powered)
  • As the basis for enhanced services such a SIP (www.cipango.org), Ajax JMS (www.activemq.org), Asynchronous SOA services (Apache Camel)

As the servlet specification continues to grow and add additional features (annotations, automatic web services, etc.) the cost of a standard servlet server is increasing. While Jetty will always continue to support the standard incarnation, its modular approach allows deployments to be targeted at precisely the set of services required without the additional complexities, inefficiencies and security concerns of unused features.

2.1. Performance

Both Jetty and Tomcat offer good request per second performance and for any non-trivial web application it is highly unlikely that either will be the main bottleneck.

General benchmarks are difficult to provide and web load profiles are greatly influenced by the actual application and there is no substitute for specific application benchmarking. However, some generalized observations can be made:

  • Tomcat tends to have slightly better performance when there are few very busy connections. It has a slight advantage in request latency, which is most apparent when many requests/responses are sent over a few connections without any significant idle time.
  • Jetty tends to have better scalability when there are many connections with significant idle time, as is the situation for most web sites. Jetty's small memory footprint and advance NIO usage allows a larger number of users per unit of available memory. Also the smaller footprint means that less memory and CPU cache is consumed by the servlet container and more cache is available to speed the execution of non-trivial applications.
  • Jetty also has better performance with regards to serving static content, as Jetty is able to use advance memory mapped file buffers combined with NIO gather writes to instruct the operating system to send file content at maximum DMA speed without entering user memory space or the JVM.

2.2. Features

Both Jetty and Tomcat implement the core standard servlet 2.5 specification. Both servers offer a range of EE inspired features such as JNDI, JTA, JMS, Mail servers, etc. Tomcat has an easy migration path for full EE towards Jboss and Geronimo. Jetty has an easy migration path for full EE towards Geronimo, JBoss, JOnAS, Sybase EAServer and, to some extent, Glassfish.

In the last 18 months, there has been an increased focus on web-2.0 features, specifically Ajax Push and Comet. Jetty has been a leader in supporting the web-2.0 use-case from within the servlet model and Webtide has formalized the Jetty approach in a proposal to JSR315for the Servlet 3.0 that is likely to be accepted as the standard way to provide the asynchronous servlets that are needed by web-2.0. In comparison, the Tomcat project was slow to accept the Web-2.0 use-case, but are now offering an async IO API that does fulfill the requirement. However that approach is not from within the servlet model, so standard frameworks (JSP, Struts, etc) and techniques cannot be used.

3. Non-Technical Comparisons

3.0. Market Share

Selecting the market leader is often used as an important selection criteria. While market share is often a good indication of technical strength, there are often many non-technical and/or historical reasons that may contribute to and devalue market share as a selection criteria -specially in a market heavy influenced by standards.

More over, the dominant market share once held by Tomcat is in decline, while Jetty's market share has been steadily increasing over the last 18 months to the point where it now has 80% of Tomcat's market share as reported in the Netcraft server surveys:

Graph of Jetty vs. Tomcat over time

The Netcraft (http://www.netcraft.com) report surveys only measure a fraction of installations as many servers have had their identifies disabled or are hidden behind load balancers or other web servers such as Apache.If installed base is to be considered, then Jetty's use in many frameworks and tools (e.g. in the Eclipse IDE from 3.3 onwards) would give Jetty a regular usage basis in the millions.

3.1. Reference Implementation

Tomcat was the reference implementation for servlets 2.4 and thus was often selected on that basis. From version 2.5 onwards, Tomcat is no longer the reference implementation. Sun Microsystems forked the Tomcat server to create Glassfish as the reference implementation for servlet 2.5 and servlet 3.0 as well as for JSP 2.1 onwards.

Jetty pays close attention to the specification and faithfully implements it. The Jetty developers were also very active on JSR-154 for servlets 2.5 and now on JSR-315 for servlets 3.0. Thus Jetty not only follows the servlet specification, but is able to influence the ongoing enhancement of the specification and to anticipate upcoming changes.

3.2. Development Community

Jetty enjoys a stable development team and process, and has the same for more than a decade. Jetty has been developed by the same core team since 1995 (using java 0.9) and has been supported by Mort Bay Consulting and now by the partnership between Webtide LLC and Mort Bay. The project lives at the independently minded codehaus.org project repository. The active group of people developing Jetty is of moderate size and of a healthy, friendly and collaborative nature. The extended community in which Jetty has developed includes close collaborations with many other open source projects including Maven, ActiveMQ, Spring, Eclipse, JBoss, Geronimo, etc.

Tomcat has unfortunate history of a fragmented development community that is characterized more by revolution than by collaboration or evolution. The transitions from Tomcat 3 to 4, 4 to 5, 5 to 5.5 and 5.5 to 6 have often resulted in the community splitting or of core developers leaving the project. The governance and development issues of Tomcat have culminated in:

  • The loss of the status as Reference Implementations
  • The forking of the project to Sun's Glassfish
  • The project has switched from Commit and Review development to Review and Commit.

The upcoming move to Servlet 3.0 is going to require non-trivial enhancements to all servlet servers. Having a unified harmonious, experienced and proven development team and process will be key to the smooth transition to the new specification and the services and features that it will support.

4. Summary

The Tomcat project is a reasonable quality Java application server that has an established brand and large user base. When used for it's prime role, Tomcat well fulfills the requirements. However it does lack the flexibility as a software component and the capability as a project and community to adapt to changing requirements and new innovative usage.

The Jetty project/team has an attitude and a history of being responsive to innovations and changing requirements. This has resulted in a well architected software platform that has been integrated and deployed in almost every environment and that is supported by a sizable, healthy and growing community.

For more information about Jetty, please check out the official Jetty website at http://jetty.mortbay.org/jetty/.

原创粉丝点击