-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Spring WebFlux and Undertow high cpu usage after perfromance test #22467
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
Comments
Thanks for the sample. I've reproduced the problem with very high CPU usage in
Sampling in JVisualVM shows that the 12 XNIO threads are using 900ms/1000ms. Looking at a thread dump, none of them have Spring (Boot or Framework) code in their stacks. Each thread's stack looks like the following:
I can't tell if this is a bug in Spring Framework, Undertow, or XNIO, but it does not look to be anything to do with Spring Boot itself. I think we should get the Framework team to take a look to see if they can narrow down the cause. |
The |
I have just come across this problem, digging a bit further I found that there is a loop where the onWritePossible handler in 'AbstractListenerWriteProcessor' is constantly called, the current state is 'REQUESTED'. |
Following up on @SillyMoo comments above, I'm seeing the same behavior. I have noticed that it does not happen when the computation of the response can happen synchronously I.E. All else being the same, the following route will trigger this behavior:
Whereas the following route will not cause this:
(CompletableFuture is being used in this example as that's where I discovered the issue in my app) It's also worth noting that this issue, in addition to causing high CPU usage, also causes the request that triggered the behavior to time out - at least in my testing. If I override the Undertow bean to replace the Webflux handler with a custom Undertow handler, as such:
The issue does not happen. It does seem to specifically be an issue in Webflux's handling of the request. |
There was recent fix in |
Spring Boot Version
Problem
Hi,
I was testing performance of 2 microservices(genareted from start.spring.io):
After services started I ran performance test using wrk. After test finished I ran htop to check cpu usage and it was still high. Only restart of application helps.
After test cpu usage:
Also tested 2 other cases:
and high cpu problem didn't occurs.
So it must be the problem with combination of WebClient and Undertow. In profiler I saw that 2 NIO threads were busy for 993ms/1000ms after test. Problem shows up only after high load.
I tried to debug through code and I found that state is REQUESTED and it looks like infinite loop which process same event.

Reproduction steps
Repository to reproduce problem with steps: https://github.com/lukidzi/springboot-undertow
The text was updated successfully, but these errors were encountered: