Jetty: interrupt long lasting requests (timeout earlier)

限于喜欢 提交于 2019-12-08 13:13:05

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/36885803/jetty-interrupt-long-lasting-requests-timeout-earlier

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!