I have started my springboot application with following tomcat parameters
-Dserver.tomcat.max-threads=400
-Dserver.tomcat.max-connections=4000
I want to monitor busy thread and busy connection size?
Is there a built-in solution inside springboot? Otherwise Do I need to get mbeans?
Found similar question but solution is not given yet.
Thanks.
To find the status of the in-use threads, Tomcat provides the ThreadPool MBean. The attributes currentThreadsBusy, currentThreadCount and maxThreads provide information on the number of threads currently busy, currently in the thread pool and the maximum number of threads that can be created.
Maximum number of threads in Spring Boot Application max-threads to control how many threads you want to allow. This is set to 0 by default which means- use the Tomcat default which is 200 .
The Current No. of threads metric is fetched as JMX metrics (it's not computed by the javaagent). The Mbean object which is used to fetch the metric is - java. lang:type=Threading.
At first, I use Spring Boot Actuator and Micrometer. But It does not show tomcat thread utilization. So I configured the application.yml like this.
server:
port: 3200
address: 0.0.0.0
tomcat:
max-threads: 4000
mbeanregistry:
enabled: true
I set server.tomcat.mbeanregistry.enabled
to true. Then Tomcat threads utilization is shown in /actuator/metrics.
This is my output.
{
"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"
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With