Java Web Server Jetty

Source: Internet
Author: User

Home page:

Http://jetty.codehaus.org/jetty/

 

Reference:

Http://blog.csdn.net/zhaozheng7758/article/details/6101346

Http://www.cnblogs.com/lexus/archive/2011/08/23/2150191.html

Http://www.cnblogs.com/yangchao/archive/2011/03/26/2044393.html

Http://www.ibm.com/developerworks/cn/web/wa-lo-jetty/

 

What is a jetty? Jetty is an open-source HTTP and web server implemented in Java, including HTTP server, HTTP client, and javax. servlet container. Similar to Tomcat, websphere, glassfish, and JBoss. Where is jetty used? Jetty is widely used, including: large-scale cluster systems such as Yahoo hadoop cluster (http://developer.yahoo.net/hadoop/) cloud computing services such as Google appengine (http://code.google.com/appengine/) SaaS (software-as-a-service) systems, such as Yahoo! Zimbra (http://www.zimbra.com/) Applications Program Servers such as Apache Geronimo (http://geronimo.apache.org/) application frameworks such as GWT (http://code.google.com/webtoolkit/) tools such as Eclipse IDE (http://www.eclipse.org/) mobile devices, I-Jetty (http://code.google.com/p/i-jetty) 3. What are the features of jetty? Jetty is widely used thanks to its many outstanding features: lightweight: jetty is small and occupies less system resources. Easy to embed: jetty can run independently like tomcat, and can be easily embedded into tools, frameworks, or other application servers for running. Jetty was designed as a Java Code Therefore, the development team provides jetty as a set of jar files, which can easily instantiate jetty into an object in its own container and manipulate the container object. Flexibility: jetty's architecture and interface-oriented design enable high plug-in and scalability of functional modules, allowing you to easily configure the features enabled by Jetty as needed. Stability: jetty runs fast. Even if a large number of concurrent service requests exist, the system performance can be kept in an acceptable state. 4. jetty's architecture the following section briefly introduces several parts: ctor Ctor is responsible for parsing server requests and generating responses. Different connector are used to process requests of different protocols. Handler is used to process requests parsed by ctor and generate response content. You can also configure different handler to process different requests. Theadpool: Manages and schedules multiple threads to serve multiple connection requests. Server represents a jetty server object. It is mainly used in collaboration with connector, handler, and theadpool. Here ,! Theadpool can be used or not based on the configuration, and connector and handler can be easily replaced by the configuration. Five continuation mechanism the continuation mechanism is jetty used to better support the asynchronous servlet mechanism. First, briefly introduce the background of technical application. Asynchronous requests mean that when a client sends a request to the server, the client does not have to wait until the server responds, such as Ajax (Asynchronous JavaScript and XML) technology in Web 2.0 and JDBC connection pool, when the server returns a response, the client uses a JavaScript function to process the returned value, so as to update the value of some elements on the page without refreshing the entire page, so as to bring a better customer experience. However, in many cases, such asynchronous events are generated only in a small part. How can we ensure that the client will know immediately after the server has a response, we have two ways to solve this problem. One is to let the browser request the server to obtain the change every several seconds, which is called polling. Second, the server maintains a persistent connection with the browser to transmit data. The persistent connection technology is called comet. The main drawback of Round Robin is that a large amount of transmission waste is generated. If comet technology is used, a long connection must be maintained between the client and the server. Generally, a servlet on the server will exclusively occupy a thread. If a large number of clients maintain persistent connections, the processing capability of the server will be greatly challenged. Based on the above situation, Jetty uses Java's non-blocking I/O technology to process a large number of concurrent connections. Specifically, Jetty implements a selectchannelconnector Based on the java. NiO API, allowing it to maintain each connection open without consuming one thread. When the connection is suspended, connector maintains the request in the pending continuations queue, and the thread used to serve the request is returned to theadpool. In this way, the thread can serve other requests. The paused request stays in the pending continuations queue until the specified expiration time, or calls the resume () method on its continuation. As the first successful Web Container, Jetty vs tomcat has a large user base. Jetty and tomcat are similar in terms of surface functions, both of which provide HTTP server and Servlet Container functions. Below we compare the differences between the two in several aspects: in terms of architecture, Tomcat is mainly designed as a reference for implementing the latest JSP/servlet specifications. It belongs to the academic school, but it looks huge and messy. The most common way to use Tomcat is to install it as a server software on the operating system, and then deploy Web applications in it, if it is embedded into other Jee servers to provide Web container functionality or as a component to be embedded into other applications, the operation is troublesome. Jetty is assembled by multiple components that can run independently through pluggable interfaces. It can be used flexibly. Currently, jetty provides Web Container functions in Jee application servers such as Geronimo, JBoss, Sybase EAServer, Jonas, and glassfish. In terms of performance, tomcat has a good execution efficiency when the number of time-consuming request connections is small, that is, when most requests are processed in a very short time. Jetty has a large number of concurrent connections, and most of the connections require more processing time (the time occupied by business logic computing) (this situation is characteristic of most web applications ), it provides better performance and scalability. Jetty's advantage is thanks to the continuation mechanism, which allows applications to use more limited memory resources. Jetty also has better performance in static file services. This is because jetty uses the File Memory ing mechanism and NiO to input and output static content, which will consume less system memory and send faster. In terms of standard specifications, Tomcat was the reference implementation of sevlet2.4 specifications. Since servlet2.5, Tomcat is no longer a reference implementation, and Sun has created glassfish, and serves as a reference for servlet2.5, servlet3.0, and jsp2.1.

Jetty is very good at implementing the specifications and is an excellent implementation of the servlet2.5 specifications. In servlet3.0, jetty's own continuation mechanism has become one of the normative alternatives.

 

 

Complete!

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.