Undertow
Undertow is a high-performance Java web server and web application framework. It is lightweight, flexible, and highly scalable, capable of efficiently handling high-concurrency requests. It supports multiple protocols (such as HTTP/1.1, HTTP/2, WebSocket, etc.) and is commonly used to build high-performance web applications and services.
Configuration¶
Enable DataKit Collectors¶
- Enable the StatsD Collector
cp /usr/local/datakit/conf.d/statsd/statsd.conf.sample /usr/local/datakit/conf.d/statsd/statsd.conf
- Enable the ddtrace Collector
cp /usr/local/datakit/conf.d/ddtrace/ddtrace.conf.sample /usr/local/datakit/conf.d/ddtrace/ddtrace.conf
- Restart Datakit
datakit service -R
Application Configuration¶
- Download
dd-java-agent
- Configure
undertow.yaml
DDTrace retrieves Undertow metrics from JavaBeans
init_config:
instances:
- jvm_direct: true
name: undertow-monitoring
collect_default_jvm_metrics: false
collect_default_metrics: false
refresh_beans: 60
conf:
- include:
bean_regex: "org.xnio:type=Xnio,provider=\"nio\",worker=\"XNIO-.*\""
attribute:
IoThreadCount:
metric_type: gauge
alias: undertow.io.thread.count
- include:
bean_regex: "jboss.threads:name=\"XNIO-.*\",type=thread-pool"
attribute:
CorePoolSize:
metric_type: gauge
alias: undertow.core.pool.size
MaximumPoolSize:
metric_type: gauge
alias: undertow.max.pool.size
ActiveCount:
metric_type: gauge
alias: undertow.active.count
LargestPoolSize:
metric_type: gauge
alias: undertow.largest.pool.size
CompletedTaskCount:
metric_type: gauge
alias: undertow.completed.task.count
PoolSize:
metric_type: gauge
alias: undertow.pool.size
GrowthResistance:
metric_type: gauge
alias: undertow.growth.resistance
MaximumQueueSize:
metric_type: gauge
alias: undertow.max.queue.size
LargestQueueSize:
metric_type: gauge
alias: undertow.largest.queue.size
SubmittedTaskCount:
metric_type: gauge
alias: undertow.submitted.task.count
RejectedTaskCount:
metric_type: gauge
alias: undertow.rejected.task.count
SpinMissCount:
metric_type: gauge
alias: undertow.spin.miss.count
QueueSize:
metric_type: gauge
alias: undertow.queue.size
KeepAliveTimeSeconds:
metric_type: gauge
alias: undertow.keep.alive.time.seconds
- Startup Command
java \
-javaagent:/xxx/dd-java-agent.jar \
-Ddd.agent.port=9529 \
-Ddd.service=demo \
-Ddd.jmxfetch.check-period=1000 \
-Ddd.jmxfetch.enabled=true \
-Ddd.jmxfetch.config.dir=/xxx/ \
-Ddd.jmxfetch.con]fig=undertow.yaml \
-jar xxxx.jar
Metrics¶
- Measurement
undertow
Metric | Description | Use Case |
---|---|---|
active_count | Active Thread Count | The number of threads currently executing tasks in the thread pool. |
completed_task_count | Completed Task Count | The total number of tasks completed since the thread pool started. |
core_pool_size | Core Thread Pool Size | The number of threads that remain active in the thread pool, even if they are idle. |
io_thread_count | I/O Thread Count | The number of threads used by the underlying XNIO framework of Undertow to handle network I/O events (e.g., accepting connections, reading/writing data). |
keep_alive_time_seconds | Thread Keep-Alive Time | The time that excess idle threads can wait before being terminated when the number of threads exceeds the core pool size. |
largest_pool_size | Largest Pool Size | The maximum number of threads reached since the thread pool started. |
largest_queue_size | Largest Queue Size | The maximum number of tasks in the task queue since it started. |
max_pool_size | Maximum Pool Size | The maximum number of threads allowed in the thread pool. This is a critical configuration parameter that limits concurrency. |
max_queue_size | Maximum Queue Size | The maximum number of tasks that the task queue can hold. |
pool_size | Current Pool Size | The total number of threads in the thread pool (including active and idle threads). |
queue_size | Current Queue Size | The number of tasks currently waiting in the task queue to be executed. A continuous increase usually indicates insufficient processing capacity. |
rejected_task_count | Rejected Task Count | The number of tasks that were rejected due to the thread pool being full (maximum threads reached and queue full) or rejection policy triggered. |