In summary: Use Tomcat to handle standard Java Container use cases, such as Servlets, JSP or framework which are built upon this stack. Use Netty If you deal a lot with network protocols and want it to be non-blocking use Netty usually for high-performance cases.
Netty allows you to write your own network protocol tailored to your specific requirements, optimizing the traffic flow for your specific situation, without the unnecessary overhead of something like HTTP or FTP.
Netty belongs to "Concurrency Frameworks" category of the tech stack, while Apache Tomcat can be primarily classified under "Web Servers". "High Performance" is the top reason why over 2 developers like Netty, while over 76 developers mention "Easy" as the leading cause for choosing Apache Tomcat.
Tomcat is an Apache project, while Jetty is managed by the Eclipse Foundation. In terms of licensing, Tomcat enjoys the Apache 2.0 open source license, while Jetty is dual licensed through both the Apache 2.0 License and the Eclipse Public License 1.0.
Jetty is a lightweight servlet container, easy to embed within a java application, there is an easy to use jetty client also.
Netty is an asynchronous event-driven network application framework. You can write your own servlet container or http client app with help of the Netty framework for example.
Edit:
Forgot to mention that Jetty 8 and Apache Tomcat 7 support servlet 3.0 spec, but netty doesn't. Because it's not a servlet container.
I think over time the overlap increases as both projects add new features.
Here is a benchmark: https://gist.github.com/dhanji/81ccc0e6652eccaf43cf
Jetty is a web server (HTTP), similar to the likes of Tomcat and such, but lighter than most servlet containers. This is closer to the traditional Java way of doing server applications (servlets, WAR files). Like Netty it is sufficiently lightweight to be embedded into Java applications.
Netty is a NIO client server framework which enables quick and easy development of network applications such as protocol servers and clients. It greatly simplifies and streamlines network programming such as TCP and UDP socket server. So Netty is focusing on helping to write NIO/non-blocking, asynchronous network programs.
If you deal a lot with network protocols and want it to be non-blocking use Netty (usually for high-performance cases). If you want a light HTTP servlet container use Jetty.
This is crude simplification, but it allows to understand the difference easily:
Netty is a framework to write TCP and UDP applications.
Jetty is a framework to write HTTP applications.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With