tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Barker" <>
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" <> wrote in message
> 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 

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:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message