如何为Tomcat并行运行多个servlet执行? [英] How to run multiple servlets execution in parallel for Tomcat?

查看:214
本文介绍了如何为Tomcat并行运行多个servlet执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Tomcat应用程序,我需要两个不同的servlet或同一个servlet来并行响应我的请求.情况是,我有第一个请求,要求下载医学成像,还有另一个AJAX客户端请求,在第一个请求完成之前获取图像.但是由于某种原因,服务器直到第一个请求结束后才响应我的第二个请求.

I have a Tomcat application, I need two different servlets or the same one to respond in parallel to my requests. The case is I have a first request asking to download medical imaging and I have another AJAX client request fetching images before the first request is completely done. But for some reason, the server does not respond to my second request until the first one is over.

为了实现并发servlet的执行,必须进行哪些更改?我们有一台不错的服务器,具有多个驱动器,多个内核.我正在使用Tomcat6.任何可以探索的想法都很棒.

What has to be changed in order to achieve concurrent servlets execution? We have a pretty good server with multiple drives, multiple cores. I'm using Tomcat 6. Any ideas to explore would be great.

推荐答案

如果发生这种情况,则与Tomcat无关.可能是您在某处使用了同步(隐式或显式).

If that happens it's not about Tomcat. Probably you're using synchronization (implicitly or explicitly) somewhere.

但是,您可以明确地管理线程池:

However you can manage thread-pooling expicitly:

 <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />

<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
        maxThreads="150" minSpareThreads="4"/>

<Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

即您可以指定最大线程数,也可以使用线程池.此处的更多信息 http://tomcat.apache.org/tomcat-5.5- doc/config/http.html

I.e. you can either specify the number of max threads or use a thread-pool. More information here http://tomcat.apache.org/tomcat-5.5-doc/config/http.html

这篇关于如何为Tomcat并行运行多个servlet执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆