跳转至

Undertow

Undertow 是一个高性能的 Java Web 服务器和 Web 应用框架,它轻量级、灵活且可扩展性强,能够高效处理高并发请求,支持多种协议(如 HTTP/1.1、HTTP/2、WebSocket 等),常用于构建高性能的 Web 应用和服务。

配置

DataKit 开启采集器

  • 开启 StatsD 采集器

cp /usr/local/datakit/conf.d/statsd/statsd.conf.sample /usr/local/datakit/conf.d/statsd/statsd.conf

  • 开启 ddtrace 采集器

cp /usr/local/datakit/conf.d/ddtrace/ddtrace.conf.sample /usr/local/datakit/conf.d/ddtrace/ddtrace.conf

  • 重启 Datakit

datakit service -R

应用配置

  • 下载 dd-java-agent

SDK

  • 配置 undertow.yaml

DDTrace 从 JavaBean 里面获取 Undertow 的指标数据

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
  • 启动命令
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 

指标

  • 指标集 undertow
指标 描述 用途
active_count 活跃线程数 当前线程池中正在执行任务的线程数量。
completed_task_count 已完成任务数 线程池自启动以来已完成的任务总数。
core_pool_size 核心线程池大小 线程池中始终保持活动的线程数,即使它们处于空闲状态。
io_thread_count I/O 线程数 Undertow 底层 XNIO 框架用于处理网络 I/O 事件(如接受连接、读写数据)的线程数量。
keep_alive_time_seconds 线程保持活跃时间 当线程数超过核心线程数时,多余的空闲线程在被终止前可以等待的时间。
largest_pool_size 历史最大线程池大小 线程池自启动以来达到的最大线程数量。
largest_queue_size 历史最大队列大小 任务队列自启动以来达到的最大任务数量。
max_pool_size 最大线程池大小 线程池允许创建的最大线程数量。这是一个关键的配置参数,限制了并发处理能力。
max_queue_size 最大队列大小 任务队列可以容纳的最大任务数量。
pool_size 当前线程池大小 当前线程池中的总线程数量(包括活跃和空闲线程)。
queue_size 当前队列大小 当前在任务队列中等待被执行的任务数量。持续增长通常表示处理能力不足。
rejected_task_count 被拒绝任务数 由于线程池已满(线程数达到最大且队列已满)或拒绝策略触发,而被拒绝执行的任务数量。

文档评价

文档内容是否对您有帮助? ×