Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Apache Tomcat »

Throttling load using semaphore in a servlet?

Robert Casties

2007-07-28


Is it OK to use a semaphore in a servlet? Are there any special problems
that arise?

My problem is that I have an image processing servlet that uses a lot of
CPU depending on certain circumstances. Therefore I want to limit the
number of concurrently running servlets running heavy operations while
at the same time continue to run servlets with only light operations.

Currently I have implemented the logic in the servlet itself using a
semaphore for the heavy operations.

Now I am running into problems with my production server (a pound proxy
serving two tomcats on two separate machines) where all semaphore
tickets are taken but no heavy operations are running.

I will continue to look in my code to see if I'm leaking semaphore
tickets but at the same time I was wondering if this was a problem with
Tomcat's own thread handling that got influenced by my semaphore.

Any thoughts?

Thanks
 Robert


---------------------------------------------------------------------
To start a new topic, e-mail: users@(protected)
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.