tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: How much connections are handled per thread?
Date Tue, 20 Dec 2011 14:46:48 GMT
Uwe.Hellmann@t-systems.com wrote:
> Hello together,
> 
> just a short question.
> Does a single Tomcat thread handle more than one connection at a time? (kind of multiplexing)

Essentially, no.

One tomcat thread could be handling several successive *requests* on the same connection,

one after the other, if KeepAlive is enabled.

But one thread will not handle multiple connections at the same time.

> Is it possible that if there are more connections at a time per thread that there is
a bug that
> a GET variable is exchanged between these connections?

You are not saying which version of Tomcat this is, which makes it hard to check if there

ever was a bug in Tomcat in that respect.

It is far more likely that it is something in your application, which does something which

is not thread-safe, and causes data to be in effect shared by various threads.
Or, something is accidentally being "remembered" by a thread which has processed a request

from a browser, and is being re-used by the same thread to process a later request from 
another browser (and another connection).

Note that the same thread can /successively/ handle several connections, and that the same

browser may be using over time several distinct connections with Tomcat.
That is not a contradiction with what I said above.

Examples :
1) a browser establishes a connection with tomcat, and sends one request to tomcat over 
that connection; then it waits for the response.  Tomcat allocates one thread to this new

connection. The thread processes the request and sends the response.  The browser reads 
the response, and then he goes away and never asks for more.  After a while (maybe 
immediately if there is no KeepAlive), the thread will close the connection and become 
available again to process a new connection.  This new connection could be from the same 
browser, or not.
2) a browser establishes a connection with tomcat, and sends one request to tomcat over 
that connection; then it waits for the response.  Tomcat allocates one thread to this new

connection. The thread processes the request and sends the response.  The browser reads 
the response, and sends another request over the same connection (because KeepAlive is 
on).  The same thread processes the second browser request and responds. This goes on as 
long as the browser is sending more requests on that connection, until the KeepAlive 
request limit is reached (maybe never, if there is no limit). When the limit is reached, 
the thread closes the connection and becomes available again for other connections.
If the browser wants to send more requests, it must create a new connection and send these

requests over that new connection.  At the tomcat level, this would be processed by a new

thread (which may by chance be the same as the first time, but that is unlikely).



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


Mime
View raw message