Reputation: 874
Related question: https://stackoverflow.com/questions/29616394/tomcat-multithreaded-application-issue
here is the jsp file:
<%
int id = new java.util.Random().nextInt(10000);
System.out.println("STARTING REQUEST: "+id);
Thread.sleep(10000);
System.out.println("ENDING REQUEST: "+id);
%>
fairly simple yet the output is
STARTING REQUEST: 6009
ENDING REQUEST: 6009
STARTING REQUEST: 2792
ENDING REQUEST: 2792
STARTING REQUEST: 4504
ENDING REQUEST: 4504
How could I possibly hope to handle even a dozen browser sessions with this kind of multitasking?
What setting am I missing in tomcat? It's a plain install with hardly any changes...
here are the parts of server.xml I have messed with:
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="4"/>
<Connector executor="tomcatThreadPool"
port="38765" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" maxThreads="150" />
If however I run each request from different browsers I get this kind of output
STARTING REQUEST: 6009
STARTING REQUEST: 2792
STARTING REQUEST: 4504
ENDING REQUEST: 2792
ENDING REQUEST: 6009
ENDING REQUEST: 4504
So I was wondering, is there a good reason why session requests are synchronized? If not, can multi-threading be enabled?
Upvotes: 1
Views: 80
Reputation: 16635
JSPs are multi-threaded by default.
Session requests are not synchronized.
The problem lies in how you are generating requests, not in how Tomcat is processing them.
Upvotes: 1