Monitoring Undertow thread pools

Finding out the runtime metrics of Undertow thread pool can be done through the JMX API. Let’s see how to do it.

Undertow web server is based on XNIO. The XNIO project provides a thin abstraction layer over Java NIO. In particular it provides two core functionalities:

  • Channel API
  • Management of IO and Worker threads

In terms of notifications, the Channels are notified of events using the ChannelListener API, however in terms of monitoring we will be focusing on the pool of IO threads and Worker threads.

The XNIO worker manages both the IO threads, and a thread pool that can be used for blocking tasks. In general undertow’s non-blocking handlers will run from withing an IO thread, while blocking tasks such as Servlet will be dispatched to the worker thread pool.

By default, there is a “default” worker in the io subsystem:

<subsystem xmlns="urn:jboss:domain:io:1.1">
    <worker name="default"/>
    <buffer-pool name="default"/>

This worker is referenced by undertow server through the worker attribute of one listener:

[standalone@localhost:9990 /] /subsystem=undertow/server=default-server/http-listener=default:read-attribute(name=worker)
    "outcome" => "success",
    "result" => "default"

The current number of active io threads (IoThreadCount) is not directly exposed through runtime attributes of undertow. In order to find out this metric, and all other relevant metrics such as the WorkerQueueSize, we will need a JMX interface, such as hawtio. (See this tutorial to learn how to install hatwio on WildFly: Getting started with Hawtio to monitor your application server )

As you can see from this picture, the metrics can be collected through the org.xnio ObjectName:

Monitoring undertow io threads

If you want to use REST to access the relevant attributes, then you can reach out for the following URLs: