Tomcat vs Jetty- What’s the Difference (Pros & Cons)

Tomcat vs Jetty- What’s the Difference (Pros & Cons). When you want to run a Java web application, you need more than a web server. You also need an application server that can process servlets. Both of those tools Jetty and Tomcat are two great choices. As both of them are web servers and Java servlet containers. Both of them are open source solutions making them ideal for small to medium scale businesses. This article will explain the main pros and cons of each tool and how they perform head to head in various aspects.  

Would you like to learn more? Let’s start on the article Tomcat vs Jetty- What’s the Difference (Pros & Cons).

What is Tomcat?

Tomcat has been living since 1999, and currently, it’s in its 10th version. You can use it freely for any commercial use as it’s licensed under Apache 2.0. Moreover Tomcat servlet container implements all core java enterprise specifications, including Jakarta Server Pages, Jakarta Servlet and Jakarta WebSocket specs. In addition Tomcat initially started as the reference implementation for the very first Java server pages and Java servlet API. Although it doesn’t work as the reference implementation for them anymore, Tomcat still retains the position of most popular application server among Java developers.  

What is more Tomcat boasts a 60% of market share among all the Java servlet containers, which is higher than all the other servlet containers combined. Some of the popular companies that use Tomcat are eBay, spring, Zillow and Mastercard. 

While Tomcat is suitable for any type of application, it’s more famous for microservices. As a result of that, popular frameworks like SpringBoot have an embedded tomcat server with it. 

Let’s see the main pros of the Tomcat server. 

Pros of Tomcat

  • First of all is very easy to install and configure tomcat on any platform. 
  • Incredibly lightweight despite it offers all the functionalities of a web server
  • There are a lot of customization options to extend its functionality. 
  • Very stable product as it has existed for a very long time. 
  • Well documented, making it easy to learn. 
  • Offers Simple web application deployment options.
  • Supports Java Enterprise.
  • Coyote engine to run several Java enterprise applications including the Java Persistence API.
  • Extra level of security to the user. 

Cons of Tomcat

  • Have a few issues in terms of memory leakage.
  • Does not have enough cluster support.
  • You may encounter problems with memory settings.
  • Not as efficient and speedy as Apache web server while dealing with static sites.
  • Doesn’t provide good understandable error messages. So you will have to check each log file deeply while troubleshooting.

Now it is time with Tomcat vs Jetty to understand Jetty Tool. 

What is Jetty?

Jetty is a part of the Eclipse foundation and started in 1995. The latest Jetty version is 11.0. So Jetty is not just a web server and servlet container. But it offers support for WebSocket, HTTP/2, OSGi, JNDI, JMX, JAAS, and many other integrations. Additionally  Jetty is popular among developers and also works as an embedded tool for a lot of frameworks, cloud services, application servers, and devices. 

According to stats Jetty maintains a market share of 10% among Java application servers. Some popular companies that use Jetty are Google, Yahoo, Nuxeo and Canva. 

Let’s find out the main pros of Jetty. 

Pros of Jetty

  • Can be used as a part of or full Java application server stack.
  • Might be applied as a part of other frameworks due to its flexibility.
  • Supports cloud style operations.
  • Jetty is user friendly and has a better interface than Tomcat.
  • Better for handling simultaneous users compared to Tomcat.
  • The conceptual weight of the framework is less, very fast, and thin.
  • Small memory trace to work speedily.
  • Users can use it easily because the required knowledge and skills are very few.

Cons of Jetty

  • Despite the development, Jetty still has startup time issues.

Similarities between Tomcat and Jetty

Both these servers implement Java server pages and servlet standards. Moreover, they have the following similarities.

  • Both these tools are open source platforms and written in Java.
  • They can process all components of the Core Java enterprise.
  • Companies use them in production environments (live releases).
  • Both tools have large community support.

Comparison between Tomcat and Jetty

1. Performance

Jetty Performance

The main priority of Jetty is reducing boot time and server memory footprint. Proves to be very critical for its high performance. As the server consumes only a small memory, more memory is available for the application. Also, due to this reason, you can have more server instances on virtual hardware. Having more instances means better load balancing improving the overall performance. Finally, a smaller memory footprint improves garbage collection, reducing the server pauses associated with it.  

Moreover, Jetty tends to improve performance when there are multiple connections with long downtimes. Thanks to low memory requirement and Non blocking I/O usage, enabling multiple user activities. 

Tomcat Performance

As for the design of Tomcat, Its performance improves when the connection is busy. This is especially true when many requests/responses are sent over multiple connections without downtime.

Also Tomcat has a better core engine and durability. Therefore the developers still consider Tomcat to be one of the best java servers.

2. Architecture

Tomcat Architecture

Architecture of Tomcat consists of a collection of functional components.  Those are server, service, Engine, host, connector, and context. They interact with each other according to the following diagram. 

Here, context represents the web application. The host can contain multiple contexts or web applications, each with different paths. The purpose of the host is to associate contexts with network names such as www.domainname.com. Connectors handle the requests that come from clients. Engine receives these requests and processes them. The server represents the whole container

Jetty Architecture

Blow you will find the architecture of the Jetty processing unit:

Primarily Jetty’s easy to install system that enables easy delivery and integration in a variety of formats:

  • From cell phones to big servers.
  • On software tools and systems: Xbean, OSGi Equinox, Tapestry, Grails, OSGi Felix, Maven, Fisheye, Spring, Continuum, Plexus, JRuby, Cocoon and more.
  • EE application services include Geronimo, Jboss, Glassfish, and Sybase EAServer.
  • Includes Cisco, Eclipse, BEA, IBM, HP, Yahoo  applications, products, and services.
  • As a foundation for advanced services such as Ajax JMS and services for asynchronous SOA, SIP, etc.

The cost for a typical servlet server will increase as servlets continually grow with new features like extensions and automation. Interestingly Jetty is capable of carrying on support for multiple installations. Due to it’s personalized approach that provides real time services without complications, delays, security issues, or missing components.

3. Features

Tomcat Features

The major specification of Tomcat is Servlet 2.5. You can extend the tomcat into a full production level web server. Basically Tomcat can be easily installed on any platform, and it’s very lightweight compared to other web server solutions. Other advanced Tomcat features are:

  • Preventing CSRF attacks (use of nonce).
  • Options to prevent session fixation attacks (By  Changing the jsessionid on authentication).
  • Detect and avoid memory leaks.
  • Asynchronous logging.
  • You can reduce the war file size by storing static resources outside war files by using Aliases. 

Jetty Features

Over the last two years, the features of Web version 2.0 for Comet and Ajax Push have gained much attention. Jetty is at the forefront of supporting Web 2.0 through the Servlet pattern. 

Another benefit is that Jetty supports next generation protocols such as SPDY, MUX, and HTTP/2.0 It also has an improved WebSocket server and client. One of the most lovable features of Jetty is it’s embeddable on other applications abilities. Let’s not forget about asynchronous HTTP client, pluggable Modules and Improved SSL Support are other key features of Jetty. 

4. Integrated tools

Various tools are integrated with Tomcat and Jetty. One one side Tomcat has integrations for tools like Apache Cocoon, Devo, SPM, Apache CXF, Boxfuse, and Lucee. While Jetty has integrations with Apache Cocoon, Lucee and Dropwizard Metrics.

5. Industry Perception

Both Tomcat and Jetty are used in most of the companies in the industry. Companies such as DocEngage, Google, Yahoo, Canva, Shutterfly, and Apache Geronimo use Jetty, while companies like eBay, Spring, Accenture, MasterCard, Zillow, and Jenkins use Tomcat. When looking into the technical behaviour of each, we can see one thing clearly. Jetty, indeed is more focused on performance while Tomcat is truly more focused on specification.

Thank you for reading Tomcat vs Jetty- What’s the Difference (Pros & Cons).

Tomcat vs Jetty- What’s the Difference (Pros & Cons) Conclusion

Summing up Tomcat is like the standard Java application server. It’s very popular and often becomes the first choice of many developers. Additionally Tomcat is very lightweight, making it ideal for small applications. However, Tomcat lacks flexibility. It’s also not as adaptable as Jetty for innovation.   

Also, when you need higher performance, Jetty is a better choice. That’s why a lot of larger companies use Jetty for production. Also, the modular nature of Jetty adds an extra advantage for microservice applications. 

Overall the selection between these two tools depends on your application. You also have to consider the other tools you have to integrate into these two servers. 

Please have a browse for more Tomcat content here.

Avatar for Shanika Wickramasinghe
Shanika Wickramasinghe

Senior Software Engineer at WSO2 which is the 6th largest Open Source Software Company in the World. My main skills are machine learning and software development. I have 5+ years of experience as a Software engineer.

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x