You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by "adj5672 (via GitHub)" <gi...@apache.org> on 2026/01/06 04:11:51 UTC

[PR] Add virtual thread attribute to WsWebSocketContainer [tomcat]

adj5672 opened a new pull request, #936:
URL: https://github.com/apache/tomcat/pull/936

   In my app, I use WsWebSocketContainer to create websocket client.
   When session count increase the more, memory usage also increased. So OOM Killed occured frequently.
   I know that It is a normal situation in thread per connection model which is current applied.
   Current model have advantage that It is very intuitive and sometimes it behaves like kind of rate limiter.
   
   But I think that thread for RW task may not working busy in some case.
   Also platform thread will be created twice of session count and it allocate a lot of default stack memory.
   furthermore context switching cost expensive too when using platform thread.
   
   So I think that instead of create two platform thread per session, using virtual thread will be helpful to memory optimization.
   Since I may not understand overall about websocket codes and architecture, I just create draft pull request.
   The point is optimizing memory usage even if virtual thread isn't.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [PR] Add virtual thread attribute to WsWebSocketContainer [tomcat]

Posted by "VolareYang (via GitHub)" <gi...@apache.org>.
VolareYang commented on PR #936:
URL: https://github.com/apache/tomcat/pull/936#issuecomment-4776775942

   Hi! I have a question: how do I enable virtual threads in Tomcat 11? After enabling virtual threads, which log in Tomcat's startup logs can I check to confirm that virtual threads are actually being used?
   
   My environment:
   Tomcat: 11.0.23
   JDK: 21
   server.xml configuration:
   <Executor name="virtualThreadExecutor" className="org.apache.catalina.core.StandardVirtualThreadExecutor" namePrefix="tomcat-virt-"/>
   <Connector executor="virtualThreadExecutor" port="8080" protocol="HTTP/1.1"
   connectionTimeout="20000"
   redirectPort="8443" />
   
   Startup logs show:
   23-Jun-2026 14:51:39.306 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
   23-Jun-2026 14:51:39.313 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [799] milliseconds
   
   When I check the thread stack with the jstack command, I don't see any threads related to tomcat-virt- so I can't be sure if virtual threads are actually enabled. Could you guide me? Thanks!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org