简体   繁体   English

使用mod_jk,tomcat和jersey,如何保持长时间运行的请求?

[英]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.

相关问题 如何在 Dropwizard/Jersey 中保持长时间运行的 HTTP 连接? - How to keep a long-running HTTP connection alive in Dropwizard/Jersey? mod_jk或mod_proxy_ajp用于集群tomcat和ssl - mod_jk or mod_proxy_ajp for clustering tomcat and ssl 我如何让tomcat 5.5在Apache 2之后运行,并且mod_rewrite将请求传递给mod_jk并剥离应用上下文? - How do I get tomcat 5.5 to run behind apache 2 with mod_rewrite passing through requests to mod_jk and stripping app context? Tomcat是否可以告诉mod_jk的负载平衡器在过载时使用另一个工作程序? 如果是这样,怎么办? - Can Tomcat tell mod_jk's load balancer to use another worker when overloaded? If so, how? 多个Apache mod_jk服务器指向同一个Tomcat工作者? - Multiple Apache mod_jk servers pointing to the same Tomcat worker? 如何为jboss EAP 6.1做mod_cluster或mod_jk集群 - how to do mod_cluster or mod_jk cluster for jboss eap 6.1 Tomcat在本地主机上未响应,但通过apache2 / mod_jk工作 - Tomcat not responding on localhost, but working through apache2/mod_jk 配置mod_jk以在CentOS7上通信Tomcat 8和Apache 2.4 - Configuring mod_jk to communicate Tomcat 8 and Apache 2.4 on CentOS7 Tomcat、mod_jk、Plesk 和 SSL 设置问题 - Tomcat, mod_jk, Plesk and SSL setup problems 使用Apache mod_jk,tomcat的后备负载均衡器 - Fallback Load balancer with apache mod_jk, tomcat
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM