code-gijoe
code-gijoe

Reputation: 7234

How to run multiple servlets execution in parallel for Tomcat?

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.

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.

Upvotes: 1

Views: 2062

Answers (1)

Eugene Retunsky
Eugene Retunsky

Reputation: 13139

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" />

or

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

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

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

Upvotes: 2

Related Questions