Lightweight alternative to Jetty

Alex picture Alex · Mar 18, 2014 · Viewed 19.9k times · Source

Usually Jetty is mentioned as the lightweight alternative when it comes to servlet containers like Tomcat and App Servers like Glassfish.

I want to run a RESTful service on CloudFoundry. Using jetty-runner

java -jar target/dependency/jetty-runner.jar target/*.war

works kind of fine, except I kind of run into problems running Jetty 9.1.3 (current stable) /w Java 8. So I contributed a patch to fix this issue and some other minor code cleanup patches. Hereby I saw the code of Jetty which was not in a shape I hoped it to be...

Well I just don't want to entrust my enterprise app to Jetty and looking for alternatives. Also with 5.x MB, jetty-runner.jar is still huge. I managed to strip it down to 1.6 MB and I was still able to run my app. So an even more lightweight approach is feasible.

Is there a lightweight version of GlassFish or Tomcat. I just need the servlet-api.jar (v3.1) being run in a web server context. No JSP, no websocket-server, no other Voodoo.

Answer

DmitryKanunnikoff picture DmitryKanunnikoff · Mar 18, 2014

Undertow is a flexible performant web server written in java, providing both blocking and non-blocking API’s based on NIO.

Undertow has a composition based architecture that allows you to build a web server by combining small single purpose handlers. The gives you the flexibility to choose between a full Java EE servlet 3.1 container, or a low level non-blocking handler, to anything in between.

Undertow is extremely lightweight, with the Undertow core jar coming in at under 1Mb. It is lightweight at runtime too, with a simple embedded server using less than 4Mb of heap space.

Link to official site.