Monitoring Undertow thread pools

User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 

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"/>
</subsystem>

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: Hawtio quickstart tutorial )

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:

http://localhost:8080/hawtio/jolokia/read/org.xnio:type=Xnio,provider="nio",worker="default"/IoThreadCount

http://localhost:8080/hawtio/jolokia/read/org.xnio:type=Xnio,provider="nio",worker="default"/CoreWorkerPoolSize

http://localhost:8080/hawtio/jolokia/read/org.xnio:type=Xnio,provider="nio",worker="default"/WorkerQueueSize

Related articles available on mastertheboss.com

How do I reload dynamically my jsp from an ear ?

  Deploy your Jsp as part of an application deployed in exploded

Where is my compiled JSP ?

JBoss recipe of the day

How do you configure JBoss to enable HTTP logging ?

To enable HTTP logging, you need to go to the deploy/jbossweb-tom

JBoss Struts tutorial

This article explains how you can setup quickly an application ba

How to restrict access to JBoss web application by IP or Host?

You can create easily Access control list based on the IP address

How do you configure a Web Application as Default Web app ?

  JBoss AS 4-5-6 First you have to remove the default