0

I would like to cancel or stop the thread where the request came in X seconds ago e.g. to avoid overloading of the system and improve overall stability. Is that possible with jetty >= 9?

I tried connector0.setIdleTimeout but it does not seem to have any effect e.g. setting it to 1000 (ms) and delaying my response 10000ms should result in a timeout but does not.

I have found similar questions on the mailing list here and here and related SO questions are here, here and here but all without a inbuilt solution from jetty.

Can't I set the read timeout of the socket somehow?

Or is this statement from the mailing list correct:

the servlet spec does not allow jetty to interrupt a dispatched thread

Community
  • 1
  • 1
Karussell
  • 17,085
  • 16
  • 97
  • 197

1 Answers1

0

Mitigating excessive load is accomplished through other means, not by harshly killing / interrupting threads (something that even the core Java Classes discourage!)

Consider using DoSFilter, QoSFilter, or LowResourceMonitor to mitigate excessive load instead.

Joakim Erdfelt
  • 46,896
  • 7
  • 86
  • 136
  • Okay, thanks! And is there a filter to send a signal or change a variable of my classes somewhere e.g. so that I can use this variable to decide if it was 'interrupted'? – Karussell Apr 28 '16 at 18:28
  • a thread cannot be interrupted successfully in jetty, the servlet spec, or the java jvm. so no. it doesn't exist. don't try to kill what's already there, try to limit the excessive issues up front, before it happens. – Joakim Erdfelt Apr 28 '16 at 20:08
  • What I mean is a safe procedure to 'kill' a thread: e.g. http://stackoverflow.com/a/11387729/194609 – Karussell Apr 29 '16 at 11:21
  • 5
    I wonder, why shouldn't a working web thread be interrupted by the server? Let's say that a working thread has been working for 10 minutes, and the web client (or a proxy server in front) has aborted the request a long time ago, then why shouldn't the thread be interrupted, so we can abort the heavy request that nobody cares about anymore? – hovenko Aug 21 '17 at 13:21