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

Autoconfigure Undertow/XNIO for virtual thread support #38819

Closed
g-dx opened this issue Dec 14, 2023 · 10 comments
Closed

Autoconfigure Undertow/XNIO for virtual thread support #38819

g-dx opened this issue Dec 14, 2023 · 10 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@g-dx
Copy link

g-dx commented Dec 14, 2023

Hi,

With the release of Spring Boot 3.2 a new property spring.threads.virtual.enabled was added which, amongst other classes, configured Tomcat and Jetty HTTP request handling to be performed using a virtual thread executor.

Are there any plans to also provide out of the box support for Undertow?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 14, 2023
@philwebb
Copy link
Member

I believe we may have looked into it but couldn't find the same kind of virtual thread support that Tomcat and Jetty were offering. @g-dx Have you seen any examples of how to configure Undertow to make use of virtual threads?

@philwebb philwebb added the status: waiting-for-feedback We need additional information before we can continue label Dec 15, 2023
@ChunMengLu
Copy link
Contributor

@philwebb @g-dx How about this:

@Bean
public UndertowDeploymentInfoCustomizer undertowDeploymentInfoCustomizer() {
 return deploymentInfo -> deploymentInfo.setExecutor(Executors.newVirtualThreadPerTaskExecutor());
}

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Dec 15, 2023
@philwebb philwebb added the for: team-meeting An issue we'd like to discuss as a team to make progress label Dec 15, 2023
@wilkinsona wilkinsona added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided for: team-meeting An issue we'd like to discuss as a team to make progress labels Jan 3, 2024
@wilkinsona wilkinsona added this to the 3.3.x milestone Jan 3, 2024
@wilkinsona
Copy link
Member

Thanks, @ChunMengLu. We'll look at doing this automatically in Spring Boot 3.3.

@JavaLionLi

This comment has been minimized.

@mhalbritter
Copy link
Contributor

As discovered in #39812, the approach with the executor doesn't work, as it leaks memory. I had to revert the change.

@dheeraj29
Copy link

Seems like memory issue is partially solved with https://issues.redhat.com/browse/UNDERTOW-2309 in 2.3.11 but still there is one open bug which occured with above release and tracked under https://issues.redhat.com/browse/UNDERTOW-2389

Once UNDERTWO-2389 is fixed, maybe virtual threads can be re-tested.

@philwebb philwebb added the for: team-meeting An issue we'd like to discuss as a team to make progress label Jun 25, 2024
@philwebb
Copy link
Member

#39812 (comment) has noted that both undertow issues are now fixed.

@philwebb philwebb removed the for: team-meeting An issue we'd like to discuss as a team to make progress label Jul 4, 2024
@mhalbritter
Copy link
Contributor

Yes, this now looks good. I've run some tests with virtual threads enabled and -Xmx256M. I don't see any exceptions in the log, the plot looks okay and the request rate is reasonable, too.

virtual-xmx-256


Summary:
  Total:	30.0004 secs
  Slowest:	0.1469 secs
  Fastest:	0.0000 secs
  Average:	0.0015 secs
  Requests/sec:	123590.2974
  
  Total data:	111221646 bytes
  Size/request:	111 bytes

Response time histogram:
  0.000 [1]	|
  0.015 [995518]	|■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  0.029 [3175]	|
  0.044 [853]	|
  0.059 [217]	|
  0.073 [118]	|
  0.088 [68]	|
  0.103 [0]	|
  0.118 [0]	|
  0.132 [0]	|
  0.147 [50]	|


Latency distribution:
  10% in 0.0001 secs
  25% in 0.0001 secs
  50% in 0.0002 secs
  75% in 0.0003 secs
  90% in 0.0006 secs
  95% in 0.0009 secs
  99% in 0.0034 secs

Details (average, fastest, slowest):
  DNS+dialup:	0.0000 secs, 0.0000 secs, 0.1469 secs
  DNS-lookup:	0.0000 secs, 0.0000 secs, 0.0004 secs
  req write:	0.0000 secs, 0.0000 secs, 0.0031 secs
  resp wait:	0.0012 secs, 0.0000 secs, 0.1466 secs
  resp read:	0.0001 secs, 0.0000 secs, 0.0037 secs

Status code distribution:
  [200]	1000000 responses

@mhalbritter
Copy link
Contributor

We need to wait for an Undertow version which has the fix for https://issues.redhat.com/browse/UNDERTOW-2420 in it.

@mhalbritter mhalbritter removed their assignment Jul 29, 2024
@mhalbritter
Copy link
Contributor

mhalbritter commented Sep 25, 2024

We have decided to ignore UNDERTOW-2420 and have upgraded the Undertow version in #42302 - so this issue can be tackled now.

@mhalbritter mhalbritter self-assigned this Sep 27, 2024
@mhalbritter mhalbritter modified the milestones: 3.x, 3.4.0-RC1 Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

8 participants