Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JvmThreadMetrics has performance issues with many threads #1805

Open
lpatouchas opened this issue Jan 17, 2020 · 7 comments
Open

JvmThreadMetrics has performance issues with many threads #1805

lpatouchas opened this issue Jan 17, 2020 · 7 comments
Labels
internal An issue that needs input from a member on another Team module: micrometer-core An issue that is related to our core module performance Issues related to general performance
Milestone

Comments

@lpatouchas
Copy link

Hello all,
we have an application that by design will have a large number of threads. We use the micrometer library as it is (outside any framework ie, spring). We define a prometheus registry and our prometheus configuration is to poll every 15seconds. We see that when our app exceeds 10-12k threads the application and even tomcat that runs it freezes after startup. If we disable the prometheus polling or remove JvmThreadMetrics the problem does not occure.

The issue is quite easy to reproduce. A simple war that generates 15k running (or even TIMED_WAITING) threads and a curl to /metrics every 5 sec will freeze the app and tomcat immediately after startup (sometimes we might get a response after a while). /metrics, /health and not even http:/hostname:8080 that should be served tomcat respond.

Is this by design, is there a finite amount of threads that this registry supports?

Regards,
Leonidas

@checketts
Copy link
Contributor

checketts commented Jan 17, 2020

That is not by design. Could you provide a sample project that reproduces it?

I suspect it is the jvm.threads.states metric since it iterates through all the threads serially (six times, one for each potential state).

If you could add a MeterFilter that disable the jvm.threads.states gauges let us know if that hang goes away.

@dedousis
Copy link

dedousis commented Jan 20, 2020

Hello,
In our test case the Tomcat just freezes for a few seconds when we curl it every some seconds.
Below i will attach the sample project we run the tests.
https://github.com/dedousis/JvmThreadMetrics

Regards
Andreas

@mauhiz
Copy link

mauhiz commented Feb 27, 2020

+1. We observed heavy impact at 4K threads, with the metrics pull thread being busy at:

Screen Shot 2020-02-27 at 18 19 18

@mauhiz
Copy link

mauhiz commented Feb 27, 2020

This JDK issue sounds related: https://bugs.openjdk.java.net/browse/JDK-8185005

@shakuzen
Copy link
Member

Looks like the fix for that JDK issue has been backported to Java 11.0.7. Once that is released, could you see if that makes any difference? With so many threads, it may be best to not use the JvmThreadMetrics. Are you wanting the thread metrics? If not, you can either not bind them or filter them out with a MeterFilter.

@shakuzen shakuzen added module: micrometer-core An issue that is related to our core module performance Issues related to general performance labels Oct 29, 2021
@shakuzen shakuzen added this to the 1.6.x milestone Oct 29, 2021
@shakuzen shakuzen changed the title JvmThreadMetrics malfunction after 10000 threads JvmThreadMetrics has performance issues with many threads Oct 29, 2021
@jonatan-ivanov jonatan-ivanov modified the milestones: 1.6.x, 1.7.x Nov 10, 2021
@shakuzen
Copy link
Member

Has anyone checked with a recent version of the JDK that includes the bug fix mentioned previously? Is the performance okay with that, or is it still an issue with enough threads?

@shakuzen shakuzen added the waiting for feedback We need additional information before we can continue label Jan 12, 2022
@shakuzen shakuzen modified the milestones: 1.7.x, 1.8.x May 11, 2022
@SoMuchForSubtlety
Copy link

SoMuchForSubtlety commented Jul 1, 2022

Has anyone checked with a recent version of the JDK that includes the bug fix mentioned previously? Is the performance okay with that, or is it still an issue with enough threads?

I'm still seeing this issue with openjdk 11.0.15. jvm.threads is the worst offender, but process.files.open, process.cpu,usage and system.cpu.usage also have a fairly large impact.

Profiling results with ~150 active threads:
image
image

@shakuzen shakuzen added internal An issue that needs input from a member on another Team and removed waiting for feedback We need additional information before we can continue labels Jul 4, 2022
@jonatan-ivanov jonatan-ivanov modified the milestones: 1.8.x, 1.9.x Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal An issue that needs input from a member on another Team module: micrometer-core An issue that is related to our core module performance Issues related to general performance
Projects
None yet
Development

No branches or pull requests

7 participants