Tune Tomcat config to reduce CLOSE_WAIT sockets
tuck Thread Detection Valve
This valve allows to detect requests that take a long time to process, which might indicate that the thread that is processing it is stuck. Additionally it can optionally interrupt such threads to try and unblock them.
When such a request is detected, the current stack trace of its thread is written to Tomcat log with a WARN level.
The IDs and names of the stuck threads are available through JMX in the stuckThreadIds and stuckThreadNames attributes. The IDs can be used with the standard Threading JVM MBean (java.lang:type=Threading) to retrieve other information about each stuck thread.
The Stuck Thread Detection Valve supports the following configuration attributes:
Java class name of the implementation to use. This MUST be set to org.apache.catalina.valves.StuckThreadDetectionValve.
Minimum duration in seconds after which a thread is considered stuck. Default is 600 seconds. If set to 0, the detection is disabled.
Note: since the detection (and optional interruption) is done in the background thread of the Container (Engine, Host or Context) declaring this Valve, the threshold should be higher than the backgroundProcessorDelay of this Container.
Minimum duration in seconds after which a stuck thread should be interrupted to attempt to "free" it.
Note that there's no guarantee that the thread will get unstuck. This usually works well for threads stuck on I/O or locks, but is probably useless in case of infinite loops.
Default is -1 which disables the feature. To enable it, the value must be greater or equal to threshold.