Undertow


A fast small and efficient web container

What is Undertow

  • A small web container
  • Supports Servlets, JSPs plus Undertow specific handlers
  • Replaced JBossWeb (Tomcat fork) in WildFly 8
  • Will be web container in EAP 7

What is undertow?

  • Fast
    • Consistently at or near the top of TechEmpower benchmarks (usually with Netty and Vert.x :)
  • Small
    • Easy to embed in programs with DSL API
    • Doesn't mandate lots of features like JSP support
  • Scalable
    • Uses asynchronous model, non-blocking by default
    • Very low overhead

Why replace jbossweb?

  • JBossWeb is a Tomcat form, inherits lots of baggage
    • Thread-per-request blocking-by-default model
    • Lots of legacy code and weird options to support
    • Full of things that are rarely used in modern world
  • People use Apache httpd as a proxy
    • Make web container fast enough you don't need to for static content
    • Use Undertow as a reverse proxy?!?
      • Java debugging > httpd debugging :)
  • Support HTTP upgrade, WebSockets, and more features

How to use it

  • Install WildFly
    • Suffer caffeine withdrawal since you don't have time to go get coffee waiting
  • Make a project embedding it

Handlers

Requests are handled using Handlers

Built in handlers for:
  • FS resources
  • redirects
  • security
  • request limiting
  • reverse proxies
  • and more


Servlets are built on top of native handlers
Uses Jasper from Tomcat for JSPs

Embedded

Undertow server = Undertow.builder()
  .addHttpListener(8080, "localhost")
  .setHandler(new HttpHandler() {
    public void handleRequest(final HttpServerExchange exchange)
                throws Exception {
      exchange.getResponseHeaders().put(Headers.CONTENT_TYPE,"text/plain");
      exchange.getResponseSender().send("Hello World");
    }
}).build();
server.start();

What to do?

  • Try it out
  • If you see things customers do in cases, check they work
    • I've filed bugs for replacement for Valve behaviour
    • and -D options

References

http://undertow.io/

http://www.techempower.com/benchmarks/

http://www.wildfly.org/

https://github.com/undertow-io/undertow/tree/master/examples


Undertow

By doctau

Undertow

  • 1,248