On Mar 19, 2013, at 8:37 PM, Caldarale, Charles R wrote:

>> From: Saurabh Agrawal [mailto:sagra...@sapient.com] 
>> Subject: Tomcat Behavior on Multiple HTTP requests from same browser
> 
>> Let's say I hit http://localhost:9001/homepage.html. Upon hitting the URL, 
>> tomcat will assign one of the worker threads (say Thread 1) from the pool
>> to the HTTP request which will be processed and then response will be sent
>> to the client. Now if I hit a link on homepage which is for login, a separate
>> HTTP request will be initiated from the same browser.
> 
>> What I want to understand is if the Tomcat will keep Thread 1 as persistent 
>> thread to server the second request (for login) from the same browser or will
>> it assign a separate thread from the pool ?
> 
> Normally, the first available thread from the pool is used for each request.  
> However, if you are using the BIO <Connector> with keep-alives enable *and* 
> the browser is using keep-alives, the same thread as long as the HTTP 
> connection is active.
> 
> See the HTTP <Connector> doc, especially the Connector Comparison at the end.
> 
> http://tomcat.apache.org/tomcat-7.0-doc/config/http.html
> 
> - Chuck

I think the most important thing to say here is that there is NO guarantee that 
the browser will always keep the connection alive, therefore there is NO 
guarantee that every request will get the same thread. You should never rely on 
having access to the same thread from one request to the next. (That is what 
HttpSessions are for.)

If you need to support 20,000 simultaneous users, you are going to need a farm 
of servers. Just one server will not be enough. One simultaneous user does not 
equal one thread needed: when a user is between requests, a thread can be 
servicing some other request. You should read the Tomcat documentation 
thoroughly, especial the sections on connection management, session management 
and clustering.

Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to