[入门交流] Jetty vs Tomcat
sangmin214
2010-09-27
由于Tomcat最初是作为servlet的参考实现,所以大家对Tomcat的熟悉程度远多于Jetty,虽然他们是同类别的产品,在功能和性能上也是各有千秋。下面我们来看看Jetty的作者对这两款产品的比较: 原文请看这里:http://www.webtide.com/choose/jetty.jsp Jetty vs Tomcat: A Comparative Analysisprepared by Greg Wilkins - May, 2008 1. IntroductionJetty 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 Comparisons2.0. ArchitectureThe 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:
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. PerformanceBoth 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:
2.2. FeaturesBoth 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 JSR315 for 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 Comparisons3.0. Market ShareSelecting 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: 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 ImplementationTomcat 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 CommunityJetty 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 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. SummaryThe 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. |