Bug 66581 - Idle threads are never destroyed in org.apache.tomcat.websocket.AsyncChannelGroupUtil
Summary: Idle threads are never destroyed in org.apache.tomcat.websocket.AsyncChannelG...
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 11
Classification: Unclassified
Component: WebSocket (show other bugs)
Version: unspecified
Hardware: PC Mac OS X 10.1
: P2 normal (vote)
Target Milestone: -------
Assignee: Tomcat Developers Mailing List
URL: https://github.com/apache/tomcat/pull...
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-27 13:39 UTC by Matt
Modified: 2023-05-02 11:18 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt 2023-04-27 13:39:03 UTC
Currently the ExecutorService used for this is as such:

ExecutorService executorService = new ThreadPoolExecutor(0, Integer.MAX_VALUE, Long.MAX_VALUE, TimeUnit.MILLISECONDS, new SynchronousQueue<>(), new AsyncIOThreadFactory());

This means that the threads never terminate and are spawned whenever a thread is not available, which for a server under a spike of load spawns many threads which never exit, consuming system resources indefinitely.

I would suggest that a saner idle timeout than Long.MAX_VALUE should be used, such as 60 seconds, unless there is a good reason I am unaware of as to why such threads should never die.
Comment 2 Mark Thomas 2023-05-02 11:18:27 UTC
Fixed in:
- 11.0.x for 11.0.0-M6 onwards
- 10.1.x for 10.1.9 onwards
-  9.0.x for  9.0.75 onwards
-  8.5.x for  8.5.89 onwards