This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
I'm using tomcat, but my question is for servlet stuff in general as well as for tomcat.
I'm trying to do some testing of something else, but I ended up making a servlet that does nothing more than Thread.sleep() for ten seconds. Then I open three browsers and have each browser hit the servlet. It takes me about two seconds to kick of the next browser manually, so I figure that the three browsers will each stop with a two second delay between each. But! It's a ten second delay!
There must be something else going on to account for your delay. Unless you have declared your servlet using the deprecated SingleThreadModel, each request will run in its own thread independent of the other threads.
Are you performing any synchronization within your servlet code?
Originally posted by Bear Bibeault: There must be something else going on to account for your delay. Unless you have declared your servlet using the deprecated SingleThreadModel, each request will run in its own thread independent of the other threads.
Are you performing any synchronization within your servlet code?
Even with SingleThreadModel, they would run parallel. The difference is that each request would have its own instance of the servlet.
Make sure it's not your browser making the requests synchronously.
I just put your code into a project and tried it with two browsers and then build a page with 5 frames that all point to the same servet.
With Firefox, the requests were stacked up and 5 requests took 10 seconds. With Konqueror, they came back in a random order and it took a litte more that 3.
To further test, I pointed a threaded load tester that I wrote at it and ran it with 20 requests. It finished in 3.615 seconds.
Using a packet sniffer, I could see that the requests/responses were synchronized with Firefox but not with Konqueror or my load tester.