Two points: excellent performance and easy configuration.
The main difference is the design philosophy. Tomcat is designed for reference implementation of the latest JSP/servlet specifications and belongs to the academic school, but it looks huge and messy. Tomcat has poor performance and is generally used as a plug-in for HTTP server (such as APACHE. Jetty is mainly designed as an embedded component of enterprise-level products and can be easily embedded into other products. Jetty is designed as a separate HTTP server. According to tests by Jetty developers, Jetty has almost the same performance as Apache. Jetty's architecture is tightly structured. JBoss and Jonas use jetty as their web iner by default. Tomcat is only optional as Web iner.
Jetty is rarely used in China. All of our current development is done on Jetty, and jetty is stable and reliable. As long as the code developed by Tomcat does not use the content in the latest JSP/servlet specifications, it is easy to port it to jetty. Jetty also supports JSP 1.2/servlet 2.3 (not enough? Haha ). It is better to use jetty in the production environment, especially in high-load environments.
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.