197

What is the main difference between Jetty and Netty?

Netty is part of Jboss, but is it the default web server container?

Does Netty support Servlets 3.0?

Christophe Roussy
  • 16,299
  • 4
  • 85
  • 85
user646584
  • 3,621
  • 5
  • 25
  • 27

4 Answers4

240

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.

moritz
  • 5,094
  • 1
  • 26
  • 33
  • 9
    Jetty is also an Http Server. it's bundled. Both Http Server and Application Server/Servlet Container – KyelJmD Nov 15 '13 at 23:35
  • 8
    I still don't see the relationship between the two. Is Netty for transport layer logic while jetty is for application layer logic? – Sridhar Sarnobat Jun 02 '15 at 06:30
  • 22
    @Sridhar-Sarnobat Yes, Netty is for the transport layer, while jetty is specifically for http oriented applications. With Netty you can optimize your message framing, and encoding/decoding very precisely, whereas you're stuck with HTTP with Jetty. – laughing_man Aug 10 '15 at 23:26
91

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.

Rafis Ganeev
  • 1,021
  • 6
  • 7
78

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.

Christophe Roussy
  • 16,299
  • 4
  • 85
  • 85
0

Look for other answers, as they provide more context, but what I found is:

  • Netty uses tidy and informative logs (even in DEBUG) - each request generates maybe 5-10 debug logs by default
  • Jetty bloats the logs with very low-level untidy logs - even simple requests generates around 50-70 debug lines, including header parsing
Danon
  • 2,771
  • 27
  • 37