Hi Mark,
I hope you're doing well!
Just wanted to follow up on my previous message regarding the troubleshooting
of the connection and thread behavior in our application. I’ve made the
suggested changes, but I'm still not seeing a noticeable change in the
keepAliveCount attribute, and the connectionCount remains at 1.
I’d appreciate any additional guidance on where I should focus next, or if
there are other specific aspects I should investigate further.
Also, any suggestions on an MBean attribute to differentiate between virtual
threads and platform threads would be really helpful.
Thanks again for your continued support!
Best regards,
Rose Mary
From: Rose Mary P T
Date: Friday, 28 March 2025 at 2:41 PM
To: Tomcat Users List
Subject: [EXTERNAL] RE: Monitoring Virtual Threads via JMX / MBeans in Tomcat
Hi Mark,
Thank you for the confirmation.
As per your suggestion, I have modified the deployed application so that it no
longer spawns any threads but instead executes a few calls. Additionally, I
kept the previous executor and connection configurations for Tomcat. However, I
still do not see any noticeable changes in the keepAliveCount attribute. The
connectionCount currently shows a value of 1.
At this point, I'm unsure of the next troubleshooting steps or what specific
aspects to investigate further. Any guidance on what to focus on next would be
greatly appreciated.
Additionally, could you suggest if there is any MBean attribute that can help
identify whether the threads being used are virtual threads or platform threads?
Thank you for your continued support.
Best Regards,
Rose Mary
From: Mark Thomas
Date: Thursday, 27 March 2025 at 9:25 PM
To: users@tomcat.apache.org
Subject: [EXTERNAL] Re: Monitoring Virtual Threads via JMX / MBeans in Tomcat
On 26/03/2025 10:38, Rose Mary P T wrote:
> Dear Tomcat Users,
> I hope this message finds you well.
> As per your previous email, we attempted to fetch the virtual thread count
> from the keepAliveCount attribute in the Catalina.ThreadPool MBean.
> For context, here is the setup we used:
>
>* We created a sample Spring Boot application that continuously creates
> virtual threads in a loop.
If the application is creating the threads then this won't work. The
(connectionCount - keepAliveCount) approach only works for virtual
threads created by Tomcat for processing requests.
If the application is creating the virtual threads then I'd suggest
adding tracking for the current number of virtual threads to the
application.
Mark
>* The application was deployed in the TOMCAT_LOCATION/webapps directory
> and started on localhost.
> In Apache Tomcat 10.1.36, we added the following configuration to the
> server.xml file to enable virtual threads:
> className="org.apache.catalina.core.StandardVirtualThreadExecutor"/>
> connectionTimeout="18000" redirectPort="8443"
> executor="tomcatExecutor"
> useVirtualThreads="true"/>
>
> Its observed in the logs that virtual threads were being created as expected.
> However, we noticed that the keepAliveCount attribute in the
> Catalina.ThreadPool MBean is showing a value of 0, even though virtual
> threads are being spawned.
> It seems that the keepAliveCount attribute does not provide a valid value for
> counting the virtual threads. We were wondering if this is expected behavior,
> or if there is a different way to monitor the virtual threads created in
> Tomcat.
> We would also like to know if there's a way to differentiate between platform
> threads and virtual threads using any MBean attribute in the Catalina service
> or elsewhere in Tomcat's MBean architecture.
> We would greatly appreciate any guidance or insights you can provide
> regarding this issue.
> Best Regards,
> Rose Mary
>
>
>
> From: Joash Jose
> Date: Wednesday, 26 March 2025 at 12:48 PM
> To: Rose Mary P T
> Subject:
>
>
>
> Begin forwarded message:
>
> From: Mark Thomas
> Subject: [EXTERNAL] Re: Monitoring Virtual Threads via JMX / MBeans in Tomcat
> Date: 6 March 2025 at 2:08:43 PM IST
> To:
> Reply-To: "Tomcat Users List"
>
> On 06/03/2025 06:29, Joash Jose wrote:
>
> Dear Apache Tomcat Support Team,
> I hope this message finds you well.
> I am writing to inquire whether Apache Tomcat (tomacat version is 10.1.33
> running on Java 21) exposes virtual thread metrics through JMX / MBeans.
> Specifically:
> Virtual Thread Visibility:
> Does Tomcat provide MBeans (e.g., under Catalina:type=Executor) to monitor
> virtual thread usage, such as active virtual thread counts, creation rate, or
> parking states?
>
> No with a few caveats - see below).
>
>
> If not, are there plans to add such metrics in future releases?
>
> No.
>
>
> Or any alternate ways with which we can monitor this from tomcat side.?
>
> (connectionCount - keepAliveCount) should be a reasonable estimate of the
> virtual threads currently being used.
>
> If the requests are synchronous (and there is little