JBoss unveil new nonblocking web server Undertow

JBoss unveil new nonblocking web server Undertow

Chris Mayer
Two months on from a radical name change to WildFly, the application server formerly known as JBoss AS has a new “high performance” and “nonblocking” server standing alongside it.
Revealed by project lead Stuart Douglas earlier today, the web server Undertow contains HTTP upgrade support, which means Java developers are able to allow multiple protocols to be multiplexed over the web port, without losing any performance. Douglas also promised support for WebSockets, including the recent Java EE 7 JSR 356, and the ability to mix handlers in Servlet 3.1.
Douglas explained that Undertow “starts in milliseconds” either embedded in an application or standalone, and contains “a fluent builder API for building deployments,” making it ideal for unit testing.
Although this is the first beta, performance appears to have been on the agenda from the start. Third party benchmarks, conducted by Tech Empower, show that Undertow outperforms rival Java web servers, including Netty and Gemini, when testing plain text and JSON responses for Hello World (shown below).
“One of the goals of Undertow was to have great performance and I am happy to say so far we have surpassed our own expectations,” Douglas added.
Listing: Hello World example
public class HelloWorldServer {

   public static void main(final String[] args) {
       Undertow server = Undertow.builder()
               .addListener(8080, "localhost")
               .setDefaultHandler(new HttpHandler() {
                   @Override
                   public void handleRequest(final HttpServerExchange exchange) throws Exception {
                       exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
                       exchange.getResponseSender().send("Hello World");
                   }
               }).build();
       server.start();
   }
}
Undertow has a “composition-based architecture” meaning developers can build a web server from single purpose handlers. The 1MB core jar for Undertow keeps it in line with JBoss’s penchant for lightweight projects. At runtime, the team claim a simple embedded server uses less than 4MB of heap space.
Undertow is the new default web server in WildFly, and the team advise this as the best method of getting your hands on it. They’re also looking for GitHub contributors and others to join the mailing list.

0 comments:

Post a Comment