码头:中断长时间的请求(较早超时) [英] Jetty: interrupt long lasting requests (timeout earlier)
问题描述
我想取消或停止X秒钟前发出请求的线程,例如以避免系统过载并提高整体稳定性. > = 9的码头有可能吗?
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?
我尝试了connector0.setIdleTimeout
,但似乎没有任何效果,例如将其设置为1000(ms)并延迟我的响应10000ms应该会导致超时,但不会超时.
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:
servlet规范不允许码头中断分配的线程
the servlet spec does not allow jetty to interrupt a dispatched thread
推荐答案
缓解过度负载的方法是通过其他方式完成的,而不是通过强行杀死/中断线程来进行(即使是核心Java类也不鼓励这样做!)
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.
这篇关于码头:中断长时间的请求(较早超时)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!