tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Barker" <wbar...@wilshire.com>
Subject Re: How can I limit the number of thread that tomcat spawn for my servlet
Date Sat, 26 May 2007 00:54:42 GMT

"Herman Schultz" <herman.schultz@gmail.com> wrote in message 
news:5dd1639d0705251042q243a5e54yc6663e2f3229ffed@mail.gmail.com...
> Hi,
>
> My understanding is tomcat will spawn a thread for each request to my
> servlet.
> How can I limit the number of thread that tomcat spawn for my servlet
> simultaneously?
>
> And let say if I limit the simulateous thread for my servlet to 10, what
> happens to the 11th request? Will it get dropped? Or Will it get queued?
>

TC 6 has the SemaphoreValve 
(http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/catalina/valves/SemaphoreValve.html)

that you could sub-class to do mostly what you want (or for TC 5 under Java 
5, grab the source and modify it).  It doesn't prevent the number of theads 
that Tomcat spawns, but it limits the number that are executing through it 
at any given time (out-of-the-box, it would be the number of threads 
accessing the Context, but you can sub-class it and override the 
controlConcurrency method to make it finer grained).  You could also look 
at the code, and do the same thing in a Filter.  In this case, the 11th 
request will get queued, at least until the browser gets tired of waiting 
for it :).

As Chris has already said, you can only limit the number of threads spawned 
at the <Connector> level.

> Thank you.
> 




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


Mime
View raw message