gpt4 book ai didi

java - 如何在一定时间后停止tomcat处理请求?

转载 作者:行者123 更新时间:2023-11-28 22:18:57 24 4
gpt4 key购买 nike

我的 tomcat 服务器持续处理某些请求超过 10 分钟。我停止了触发这些请求的客户端,但随后 tomcat 也继续处理这些请求。

我在 tomcat 的 server.xml 文件中尝试了 connectionTimeout 属性的不同设置,但它不起作用。

我想知道如何配置 tomcat,以便 tomcat 杀死/停止处理花费超过特定时间(如 10 秒或 1 分钟等)的请求。

最佳答案

来自 The Apache Tomcat Connector - Generic HowToTimeouts

JK can also use a timeout on request replies. This timeout does not measure the full processing time of the response. Instead it controls, how much time between consecutive response packets is allowed.

In most cases, this is what one actually wants. Consider for example long running downloads. You would not be able to set an effective global reply timeout, because downloads could last for many minutes. Most applications though have limited processing time before starting to return the response. For those applications you could set an explicit reply timeout. Applications that do not harmonise with reply timeouts are batch type applications, data warehouse and reporting applications which are expected to observe long processing times.

If JK aborts waiting for a response, because a reply timeout fired, there is no way to stop processing on the backend. Although you free processing resources in your web server, the request will continue to run on the backend - without any way to send back a result once the reply timeout fired.

关于java - 如何在一定时间后停止tomcat处理请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30573112/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com