为了账号安全,请及时绑定邮箱和手机立即绑定

监控Springboot 2.0 Tomcat服务器线程利用率

监控Springboot 2.0 Tomcat服务器线程利用率

慕丝7291255 2023-06-14 16:05:24
我已经使用以下 tomcat 参数启动了我的 springboot 应用程序-Dserver.tomcat.max-threads=400 -Dserver.tomcat.max-connections=4000我想监控繁忙的线程和繁忙的连接大小?springboot里面有内置解决方案吗?否则我需要获得 mbean 吗?
查看完整描述

3 回答

?
手掌心

TA贡献1942条经验 获得超3个赞

起初,我使用 Spring Boot Actuator 和 Micrometer。但它不显示 tomcat 线程利用率。所以我这样配置了application.yml。


server:

  port: 3200

  address: 0.0.0.0

  tomcat:

    max-threads: 4000

    mbeanregistry:

      enabled: true

我设置server.tomcat.mbeanregistry.enabled为真。然后 Tomcat 线程利用率显示在 /actuator/metrics 中。


这是我的输出。

{

  "names": [

    "http.server.requests",

    "http.server.requests.histogram",

    "jvm.buffer.count",

    "jvm.buffer.memory.used",

    "jvm.buffer.total.capacity",

    "jvm.classes.loaded",

    "jvm.classes.unloaded",

    "jvm.gc.live.data.size",

    "jvm.gc.max.data.size",

    "jvm.gc.memory.allocated",

    "jvm.gc.memory.promoted",

    "jvm.gc.pause",

    "jvm.memory.committed",

    "jvm.memory.max",

    "jvm.memory.used",

    "jvm.threads.daemon",

    "jvm.threads.live",

    "jvm.threads.peak",

    "jvm.threads.states",

    "logback.events",

    "process.cpu.usage",

    "process.files.max",

    "process.files.open",

    "process.start.time",

    "process.uptime",

    "system.cpu.count",

    "system.cpu.usage",

    "system.load.average.1m",

    "thread.pool.core.size",

    "thread.pool.max.size",

    "thread.pool.pool.size",

    "thread.pool.thread.count",

    "tomcat.cache.access",

    "tomcat.cache.hit",

    "tomcat.global.error",

    "tomcat.global.received",

    "tomcat.global.request",

    "tomcat.global.request.max",

    "tomcat.global.sent",

    "tomcat.servlet.error",

    "tomcat.servlet.request",

    "tomcat.servlet.request.max",

    "tomcat.sessions.active.current",

    "tomcat.sessions.active.max",

    "tomcat.sessions.alive.max",

    "tomcat.sessions.created",

    "tomcat.sessions.expired",

    "tomcat.sessions.rejected",

    "tomcat.threads.busy",

    "tomcat.threads.config.max",

    "tomcat.threads.current"

  ]

}


查看完整回答
反对 回复 2023-06-14
?
跃然一笑

TA贡献1826条经验 获得超6个赞

一种简单的方法是使用上面带有测微计的弹簧执行器。您可以获得即时的 JMX 指标,也可以声明您自己的自定义指标。



查看完整回答
反对 回复 2023-06-14
?
侃侃无极

TA贡献2051条经验 获得超10个赞

您可以使用Spring Boot Actuator(/metrics 端点)来提供有关内存、堆、处理器、线程、加载的类、卸载的类、线程池等信息。

例如,此端点返回:

"threads.peak" : ...,
"threads.daemon" : ...,
"threads" : ...,

此外,如果需要,您可以使用 /threaddump 端点获取线程转储。


查看完整回答
反对 回复 2023-06-14
  • 3 回答
  • 0 关注
  • 368 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号