Discussion:
StuckThreadDetectionValve with threads on IO
Behrooz Nobakht
2018-10-04 00:08:17 UTC
Permalink
[1] uses a time based threshold to mark a request thread as "stuck" above
the configured threshold.

This is definitely useful, but maybe a thread is busy transferring a large
request (IO). This could become
a wrong conclusion for the thread to be marked as stuck.

A relevant contextual example is that nginx has proxy_read_timeout [2]
(although Tomcat is not by definition a proxy)
The above checks if the server is transmitting any bytes over the wire
(socket read timeout) to decide if a request is stuck or not.

I am wondering if there's a similar way to achieve the same in Tomcat
(possibly without using NIO connectors)?

Thanks,
Behrooz


[1]:
https://github.com/apache/tomcat/blob/TOMCAT_9_0_12/java/org/apache/catalina/valves/StuckThreadDetectionValve.java
[2]:
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_read_timeout
Mark Thomas
2018-10-04 14:02:07 UTC
Permalink
Post by Behrooz Nobakht
[1] uses a time based threshold to mark a request thread as "stuck" above
the configured threshold.
This is definitely useful, but maybe a thread is busy transferring a large
request (IO). This could become
a wrong conclusion for the thread to be marked as stuck.
A relevant contextual example is that nginx has proxy_read_timeout [2]
(although Tomcat is not by definition a proxy)
The above checks if the server is transmitting any bytes over the wire
(socket read timeout) to decide if a request is stuck or not.
I am wondering if there's a similar way to achieve the same in Tomcat
(possibly without using NIO connectors)?
It should be possible with a custom Valve. It would need to be along
similar lines to the StuckThreadDetectionValve but record more
information. Namely the response object and the last value of
response.getBytesWritten(false).

The idea is that on each cycle of the background process, you'd check
the current value of response.getBytesWritten(false) and compare it to
the last.

HTH,

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org

Loading...