You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by adamle <ad...@levitt.net> on 2006/12/20 10:32:33 UTC

Limit Num Requests

Hello,

I'm running a j2EE with Apache front end and Tomcat at the back accessing a
MySQL db.  I have some heavy urls, can take around 2 seconds each call.
While testing the site with JMeter if I put 25 users in a thread group and
hit the above url concurrently I kill my tomcat instance.
This means that someone could bring my site down with the above method?
I'm looking for some way to stop this happening.  Could be caused by by
ajp13 connector?
I'm not looking for a solution to cut down the time it takes to service each
request, with caching for instance.

Thanks in advance,
Adam.
-- 
View this message in context: http://www.nabble.com/Limit-Num-Requests-tf2858769.html#a7987047
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
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


RE: Limit Num Requests

Posted by adamle <ad...@levitt.net>.
That's not a bad idea, I will look into.

Thanks again for the help.


Peter Crowther wrote:
> 
>> From: adamle [mailto:adam@levitt.net] 
>> I thought of maybe putting a filter on the certain url 
>> pattern that I want,
>> but instead of turning back the user, I could put his thread 
>> to sleep for
>> aset amount of time and have him try again.  Hopefully by 
>> then some of the
>> earlier threads will have finished and he can be let through.
>> 
>> Do you some inherent problem with this?
> 
> I'd always be cautious about consuming any resource for an extended
> period - in this case a thread.  An attacker could starve Tomcat of
> threads by flooding the system with requests for the slow-processing
> pages.  You probably wouldn't get a crash; you *would* get very slow
> service elsewhere.
> 
> Is there no way you can hand back a 'try later' response, even using
> something tacky like a refresh header?
> 
> 		- Peter
> 
> ---------------------------------------------------------------------
> 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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Limit-Num-Requests-tf2858769.html#a7988094
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
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


RE: Limit Num Requests

Posted by adamle <ad...@levitt.net>.
Thanks for the idea Peter.

I thought of maybe putting a filter on the certain url pattern that I want,
but instead of turning back the user, I could put his thread to sleep for
aset amount of time and have him try again.  Hopefully by then some of the
earlier threads will have finished and he can be let through.

Do you some inherent problem with this?

Thanks,
Adam.



Peter Crowther wrote:
> 
>> From: adamle [mailto:adam@levitt.net] 
>> I am looking for a solution that for a certain url pattern 
>> only allows a
>> certain number of requests to be serviced at the same time.  
>> This would
>> solve my problem, while not affecting servicing lighter pages.
> 
> Makes sense.
> 
> If you can stand for your users to get a 'Busy, please try again later'
> message, then one approach would be to put a Filter in front of the
> relevant pages.  Whenever it sends a request for processing, it
> increments a filter-wide counter; whenever a request returns from
> processing, it decrements the counter; if the counter is above a certain
> value when the request comes in, don't forward the request and show the
> client a try-later message.
> 
> If this isn't appropriate, I'm out of ideas - but I'm a lightweight on
> this forum, and have never used AJP.  I suspect some of the better minds
> on here will weigh in later!
> 
> 		- Peter
> 
> ---------------------------------------------------------------------
> 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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Limit-Num-Requests-tf2858769.html#a7987715
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
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


RE: Limit Num Requests

Posted by adamle <ad...@levitt.net>.
Thanks for the reply Peter.

I am caching these pages after they are processed, but because of the nature
of the application, they are many different kinds of these pages.

Tomcat does not even throw an exception, I have allocated 128-356 mb memory. 
It just dies and does not response to requests.

I am looking for a solution that for a certain url pattern only allows a
certain number of requests to be serviced at the same time.  This would
solve my problem, while not affecting servicing lighter pages.

Cheers,
Adam.



Peter Crowther wrote:
> 
>> From: adamle [mailto:adam@levitt.net] 
>> While testing the site with JMeter if I put 25 users in a 
>> thread group and
>> hit the above url concurrently I kill my tomcat instance.
> 
> What's the error?  Do you run out of memory, for example?  How much
> memory have you allocated to the JVM?
> 
>> I'm looking for some way to stop this happening.
> 
> Cut down the number of worker threads in Tomcat to limit the number of
> requests that are processed concurrently?  Note that this has the
> unpleasant side-effect of throttling Tomcat's request processing even
> for the lighter pages that don't cause problems.
> 
>> Could be caused by ajp13 connector?
> 
> Much more likely to be an application issue - there are plenty of other
> people on this list who run Tomcat with significantly higher loads than
> that with no issues.
> 
>> I'm not looking for a solution to cut down the time it takes 
>> to service each request, with caching for instance.
> 
> Then you are probably excluding your actual problem from consideration,
> and you will be applying sticking plaster to a broken leg because you're
> not willing to consider the real problem.
> 
> 		- Peter
> 
> ---------------------------------------------------------------------
> 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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Limit-Num-Requests-tf2858769.html#a7987388
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
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