I try to use virtual thread on Apache Tomcat 10.1.16 with this configuration:
<Executor name="tomcatThreadPoolVirtual" class="org.apache.catalina.core.StandardVirtualThreadExecutor"/> <Connector port="8080" protocol="org.apache.coyote.http11.Http11Nio2Protocol" connectionTimeout="20000" redirectPort="8443" maxParameterCount="1000" useVirtualThreads="true" />
But when I make a request, I'm not on a virtual thread : Thread[#76,Thread-14,5,main] . I profiled my application too but no virtual threads are used.
If I use a Http11NioProtocol instead of Http11Nio2Protocol, all requests are on virtual thread : VirtualThread[#65,http-nio-8080-virt-0]/runnable@ForkJoinPool-1-worker-1
<Executor name="tomcatThreadPoolVirtual" class="org.apache.catalina.core.StandardVirtualThreadExecutor"/> <!-- A "Connector" represents an endpoint by which requests are received org.apache.coyote.http11.Http11Nio2Protocol and responses are returned. Documentation at : HTTP Connector: /docs/config/http.html AJP Connector: /docs/config/ajp.html Define a non-SSL/TLS HTTP/1.1 Connector on port 8080 --> <Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol" connectionTimeout="20000" redirectPort="8443" maxParameterCount="1000" useVirtualThreads="true" />
Http11Nio2Protocol is not working with virtual threads? Has anyone encountered this problem before?
<Executor name="tomcatThreadPoolVirtual" class="org.apache.catalina.core.StandardVirtualThreadExecutor"/> <Connector port="8080" protocol="org.apache.coyote.http11.Http11Nio2Protocol" connectionTimeout="20000" redirectPort="8443" maxParameterCount="1000" useVirtualThreads="true" />
But when I make a request, I'm not on a virtual thread : Thread[#76,Thread-14,5,main] . I profiled my application too but no virtual threads are used.
If I use a Http11NioProtocol instead of Http11Nio2Protocol, all requests are on virtual thread : VirtualThread[#65,http-nio-8080-virt-0]/runnable@ForkJoinPool-1-worker-1
<Executor name="tomcatThreadPoolVirtual" class="org.apache.catalina.core.StandardVirtualThreadExecutor"/> <!-- A "Connector" represents an endpoint by which requests are received org.apache.coyote.http11.Http11Nio2Protocol and responses are returned. Documentation at : HTTP Connector: /docs/config/http.html AJP Connector: /docs/config/ajp.html Define a non-SSL/TLS HTTP/1.1 Connector on port 8080 --> <Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol" connectionTimeout="20000" redirectPort="8443" maxParameterCount="1000" useVirtualThreads="true" />