Jetty and tomcat Selection: Depends on the scenario

Source: Internet
Author: User

Jetty and tomcat are two of the world's most famous open-source webserver/servlet containers. Since their implementation complies with the java servlet specification, a Java Web application can be deployed on either of the two containers. But which one is better? Maybe this depends on the scenario.

Recently, many people are concerned about jetty, probably because Gae has chosen jetty because it gave up tomcat. As a result, Jetty is more in line with Gae needs, that is, cloud environments, and distributed environments. What is the difference between jetty and tomcat? I did some research and saved my friends and friends who are familiar with Tomcat and jetty and came to the following conclusion:

1) Jetty is more lightweight. This is relative to Tomcat.

As Tomcat not only complies with the java servlet specification, it also extends a large number of Jee features to meet the needs of enterprise-level applications, so Tomcat is more important and the configuration is much more complicated than jetty. However, for a large number of common Internet applications, other advanced features of Tomcat are not required. In this case, it is a waste of resources to use tomcat. This disadvantage is especially obvious in a distributed environment. With jetty, each application server saves several megabytes of memory, while in a large distributed environment, it saves a lot of resources. In addition, jetty's lightweight model makes it faster and more efficient in handling highly concurrent fine-grained requests.

 

2) Jetty is more flexible, reflected in its plug-in and scalability. It is easier for developers to perform secondary development on Jetty and customize a web server suitable for their own needs.

In contrast, heavyweight Tomcat originally supports too many features, and the cost of slimming down it is much higher than the cost of enriching jetty. With your own understanding, it is easy to lose weight by increasing fat.

 

3) However, Jetty may need to be extended to support large-scale enterprise-level applications. In this scenario, Tomcat is better.

 

Conclusion: jetty meets the requirements of the public cloud distributed environment, while Tomcat is more in line with the enterprise-level environment.

Gae gave up Tomcat and chose Jetty. It is precisely because of jetty's volume and flexibility that Google can better customize a small enough Java Web server to serve its Gae. To meet more enterprise-level requirements, Tomcat adds the Jee feature, which is better than jetty in serving enterprise-level applications. However, even if Tomcat performance is slightly better than jetty, it is too heavyweight for most non-enterprise applications to configure complicated and bulky tomcat. Because of this, the cloud platform implementation of the laboratory is to put the portal website of the cloud platform itself in Tomcat, And the Java Web hosted by cloud platform should be deployed in jetty.      

Comparison between jetty and tomcat

 

Similarities:

1. Tomcat and jetty are both servlet engines that support standard servlet specifications and javaee specifications.

 

 

Differences:

1. Architecture comparison

Jetty's architecture is simpler than Tomcat's

Jetty's architecture is implemented based on handler. The main extended functions can be implemented using handler, which is simple to expand.

The Tomcat architecture is designed based on containers. To expand the architecture, you need to understand the overall design structure of Tomcat, which is not easy to expand.

 

2. Performance Comparison

Jetty and tomcat have little performance difference.

Jetty can simultaneously process a large number of connections and maintain connections for a long time. It is suitable for Web chat applications.

Jetty has a simple architecture. Therefore, as a server, Jetty can load components as needed to reduce unnecessary components, reduce server memory overhead, and thus improve server performance.

By default, Jetty uses NiO to stop processing I/O requests, which leads to higher performance when processing static resources.

 

Tomcat is suitable for handling a few very busy links, that is, if the link life cycle is short, tomcat has a higher overall performance.

By default, Tomcat uses bio to process I/O requests. It has poor performance when processing static resources.

 

3. Other comparisons

Jetty's applications are faster, easier to modify, and better support for new servlet specifications.

Currently, Tomcat is widely used and supports javaee and Servlet more comprehensively. Many features will be integrated directly.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.