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

Jetty 10.0.20 QueuedThreadPool setting Virtual Threads #11646

Closed
cnarsimharaju opened this issue Apr 11, 2024 · 4 comments
Closed

Jetty 10.0.20 QueuedThreadPool setting Virtual Threads #11646

cnarsimharaju opened this issue Apr 11, 2024 · 4 comments
Labels

Comments

@cnarsimharaju
Copy link

cnarsimharaju commented Apr 11, 2024

Jetty Version
Jetty 10.0.20
Jetty Environment

Java Version
JDK 21.0.2.jdk
Question
We are migrating our jersey application project to JDK 21. We set QueuedThreadPool to use the Virtual Threads as mentioned in the doc. When the jetty thread run still i am seeing the native thread instead of the virtual thread. I saw a comment about it spring-projects/spring-boot#35703 (comment) is this true?

I saw on one virtual thread in my list of threads. PFA image for reference.
Error

@joakime
Copy link
Contributor

joakime commented Apr 11, 2024

Jetty 10 and Jetty 11 are both at End of Community Support

You should be using Jetty 12 at this point in time.

Since you are using Jetty 10 now, I would recommend using the ee8 layer on Jetty 12 to maintain your support of javax.servlet namespace.

Once you are on Jetty 12, you'll be able to use the up to date Virtual Hosts configurations that Jetty 10 lacks.
If you still have questions while on Jetty 12, we'll be able to help.

@sbordet
Copy link
Contributor

sbordet commented Apr 13, 2024

@cnarsimharaju Jetty still uses platform threads for its internal implementation.
You should not worry about the implementation details.
Your application code will be called by a virtual thread.
This is the same in any Jetty version from 10 upwards.

@sbordet sbordet closed this as completed Apr 13, 2024
@cnarsimharaju
Copy link
Author

Thanks a lot!. closing the thread by sharing more details. In the image which i shared above even though name was VirtualThreads it was a platform thread.

I found this "Jetty uses platform threads to schedule some of the operations needed to accept a HTTP connection. The dispatch to user code is then done with virtual threads.
Ref: spring-projects/spring-boot#35703 (comment)

Not Recommend Options: spring-projects/spring-boot#35703 (comment)

new QueuedThreadPool(200, 0, 60000, 0, null, null, Thread.ofVirtual().name("jetty-", 0).factory());

Creates a pool which is only using virtual threads (200 max, 0 min, 60s idle time). But this pools virtual threads (which is not recommended) and may have other side effects on performance or otherwise. I think it's a good idea to stick to the Jetty programming guide.

@sbordet
Copy link
Contributor

sbordet commented Apr 15, 2024

new QueuedThreadPool(200, 0, 60000, 0, null, null, Thread.ofVirtual().name("jetty-", 0).factory());

This is not a good idea, because it is a pool is virtual threads, which is an anti-pattern.

Just follow the documentation:
https://eclipse.dev/jetty/documentation/jetty-12/programming-guide/index.html#pg-arch-threads-thread-pool-virtual-threads

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants