Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lightweight alternative to Jetty

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.

like image 486
Alex Avatar asked Mar 18 '14 07:03

Alex


2 Answers

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.

like image 107
DmitryKanunnikoff Avatar answered Sep 21 '22 14:09

DmitryKanunnikoff


Since you tagged this as Jersey, I'll mention that the Jersey docs show examples of how to deploy using the HTTP server that is built-in to the Java runtime:

https://jersey.java.net/documentation/latest/deployment.html#deployment.http

like image 45
Harald Avatar answered Sep 23 '22 14:09

Harald