jetty / jetty.project

Eclipse Jetty® - Web Container & Clients - supports HTTP/2, HTTP/1.1, HTTP/1.0, websocket, servlets, and more
https://eclipse.dev/jetty
Other
3.86k stars 1.91k forks source link

Jetty 10.0.20 QueuedThreadPool setting Virtual Threads #11646

Closed cnarsimharaju closed 7 months ago

cnarsimharaju commented 7 months ago

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 https://github.com/spring-projects/spring-boot/issues/35703#issuecomment-1645084902 is this true?

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

Error
joakime commented 7 months ago

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 commented 7 months ago

@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.

cnarsimharaju commented 7 months ago

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: https://github.com/spring-projects/spring-boot/issues/35703#issuecomment-1645138684

Not Recommend Options: https://github.com/spring-projects/spring-boot/issues/35703#issuecomment-1578308622

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 commented 7 months ago

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