Jetty comparison with Tomcat and Performance Analysis

Source: Internet
Author: User

Mainstream Java Web containers are tomcat, JBoss, Jetty, and resin. We used jboss4.0.5 in the past, but the servlet container used by jbosse is Tomcat 5.5. Therefore, we only compare Tomcat and jetty, you only know. Resin is not mentioned. It seems that it has become history.

I. Tomcat

Now the tomcat version is 8.0, and many new features are added in Tomcat 6 and 7.

 

Version features

Tomcat7 Series

Tomcat6 Series

Ii. Jetty

Due to jetty's poor birth, unlike tomcat, which grew up under the powerful foundation of Apache, there were many changes. Now, under the eclipse Foundation, official documents are not as detailed and clear as Tomcat. Currently, jetty's latest version is 8.0.4. In this issue, we use jetty7.2.0. The two versions are different from jetty6. Learn more and learn about the performance in detail.

Iii. Comparison
Name Accessibility Performance Update frequency Scalability
Tomcat Easy Support NiO from tomcat6, outstanding performance Normal Not good
Jetty Relatively slow. Flexibility brings complexity. The default value is NiO, with excellent performance. Fast Good

 

To sum up, we actually choose jetty or Tomcat not because Jetty is better than tomcat, but because of what we use and what we use.

Iv. Comparison of NiO and bio

Test environment:

Tomcat: 7.0.22 JDK: 1.6.0 _ 11 system: Linux, is our development machine scenario: visit a simple JSP page, there is no business code, test and process the performance and concurrency of requests. In general, Bio is relatively stable, while NiO fluctuates greatly. However, in the case of 10240 concurrency, bio was completely completed, while NiO was still strong. Therefore, NiO is the best choice for high concurrency.

Tomcat NiO and bio configuration and Runtime

Name Configuration Runtime
Bio
NIO

5. Why jetty?

In fact, this article mainly aims to explain three points.

  1. In Web containers, we must keep pace with the times, not just pursue the present. In high concurrency, we must have relevant experience and countermeasures.
  2. NIO is better than bio, while jetty also recommends NiO
  3. Jetty's flexibility and small size, fast loading speed, and convenient debugging all prompted us to choose many Tomcat companies for the same use. In fact, Tomcat is still very good. Using tomcat to support 2000 concurrent jobs is also a common task. The reason for choosing Jetty is not much said. JBoss is not powerful and big, and tomcat does not support it. So jetty becomes the best choice in the project. Of course, Jetty is also a very good product. To sum up, the performance difference between Tomcat and jetty is not big. Jetty is more resource-saving in some scenarios (such as virtual machines and embedded systems) due to its flexibility and plug-ins. Of course, Jetty can ignore this factor for our current applications. Let's take a closer look at our SQL statements and business logic code!
Add new features of 3.1 servlet3.0.
  1. Asynchronous processing support: With this feature, the servlet thread does not need to be blocked until the service processing is complete before the response is output, and the servlet thread is terminated. After receiving the request, the servlet thread can delegate the time-consuming operation to another thread for completion, and return the result to the container without generating a response. This will greatly reduce the occupation of server resources and increase the speed of concurrent processing for time-consuming business processing.
  2. Added annotation support: This version adds several annotations for simplifying servlet, filter, and listener declarations, which makes the web. the XML deployment description file is no longer required from this version.
  3. Plug-in support: developers familiar with struts2 will remember the integration features of various common frameworks including spring through plug-ins. Encapsulate the corresponding plug-ins into jar packages and place them in the class path. These plug-ins can be automatically loaded during struts2 runtime. Currently, Servlet 3.0 provides similar features. developers can easily expand the functions of existing Web applications through plug-ins without modifying the original applications.

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.