[英]With mod_jk, tomcat, and jersey, how do you keep a long running request alive?
On the client side, we are using HttpClient for communication. 在客户端,我们使用HttpClient进行通信。 On the server side we are using Jersey and tomcat.
在服务器端,我们使用Jersey和tomcat。
Our requests look like this 我们的要求是这样的
client -> load balancer -> server 客户端 - >负载均衡器 - >服务器
The problem is this, a client will make a request to the server; 问题是这样,客户端会向服务器发出请求; That request spills over the 180 second timeout for mod_jk which causes the load balancer to kill off the connection.
该请求溢出了mod_jk的180秒超时,导致负载均衡器终止连接。 What I need is some way to signal to mod_jk that "yes, this connection is alive and progressing" so that it doesn't terminate the connection.
我需要的是向mod_jk发信号通知“是的,这个连接是活着的并且正在进行”的一些方法,这样它就不会终止连接。 Alternatively, it would be nice if we could signal to mod_jk that "This request may take a long time".
或者,如果我们可以向mod_jk发出“此请求可能需要很长时间”的信号,那将是很好的。
Our not great solution right now in the load balancer we have bumped up the socket_timeout to 20 minutes. 我们现在在负载均衡器中没有出色的解决方案,我们已经将socket_timeout提升到20分钟。 The better solution is to get the server to signal that it is still working.
更好的解决方案是让服务器发出信号表明它仍在工作。 The best solution is to make the request run faster (it tops out at 12 minutes).
最好的解决方案是让请求运行得更快(最长时间为12分钟)。
How can I make the server signal that it is still moving forward? 如何使服务器发出信号表明它仍在前进? Unfortunately sending down partial data doesn't really work well for us as this request is to get an expensive and large object and the object really isn't streamable.
不幸的是,发送部分数据对我们来说并不是很有效,因为这个请求是为了得到一个昂贵的大对象而且该对象确实不是可流动的。
Tomcat has different implementations of the response output stream. Tomcat具有不同的响应输出流实现。
The different behavior is caused by the AJP connector which connects the load balancer and Tomcat (just guessing you use AJP). 不同的行为是由连接负载均衡器和Tomcat的AJP连接器引起的(只是猜测你使用的是AJP)。 With Tomcat standalone one can write to the response output stream and the content is buffered .
使用Tomcat独立版,可以写入响应输出流并缓冲内容。 When you write to a response output stream which is backed by the AJP connector the content is flushed immediately .
当您写入由AJP连接器支持的响应输出流时,会立即刷新内容。 That makes sense because if there isn't a constant stream of data passed from Tomcat to load balancer it will "hang up" after while treating this as a timeout.
这是有道理的,因为如果没有从Tomcat传递到负载均衡器的恒定数据流,它会在将其视为超时后“挂断”。
So, I suggest you find some way of continuously or periodically sending "some data" while the real response pay load is being prepared. 所以,我建议你找到一些方法,在准备真实的响应工资负载时,不断或定期发送“一些数据”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.