tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felix Schumacher <felix.schumac...@internetallee.de>
Subject Re: Limiting threads per context
Date Thu, 03 Jan 2013 20:49:34 GMT
Am 03.01.2013 15:31, schrieb kharper2@oreillyauto.com:
> Hello All,
>
> Yesterday we had a Tomcat6 server reach maxThreads and stay that way until
> we restarted it.  After researching a thread dump and some log files, we
> found one of the applications is creating NullPointerExceptions and
> subsequently leaving a TP-ProcessorX in WAITING state indefinitely for a DB
> closePreparedStatement return.  As more requests come in for this
> application threads are being established and put into BLOCKED state,
> waiting on TP-ProcessorX.  Eventually, the server hits maxThreads and stops
> serving requests almost entirely.
>
> Obviously the application causing this needs to (and is being) fixed.  But
> I'm curious if there is a higher level of protection that could be
> implemented to help protect the other applications (contexts) on this
> server?  For example, is there a way to specify that a context can only use
> X number of request threads?  Or perhaps X number of threads from an
> executor?  Et cetera.

On tomcat 6 - at least the most recent one - there is a Valve which can 
limit the concurrent access to a context. Sadly it seems not to be 
mentioned in the docs. So you would have to look at the code to see the 
possible params (concurrency [=10], fairness [=false], blocking [=true], 
interruptible [=false]) and the name 
(org.apache.catalina.valves.SemaphoreValve) to be able to add the 
(hopefully) right entry to your context:

  <Valve class="org.apache.catalina.valves.SemaphoreValve"
      concurrency="25"
      blocking="false"
   />

I haven't tested it, but it should limit the concurrent threads used by 
that context to 25 at most and give an error to any request while those 
threads stay busy.

Regards
  Felix
>
> I haven't seen anything in the docs that would do this, but it never hurts
> to ask.  Here's our server info in case it's helpful:
> OS: Ubuntu 12.04 64-bit
> Front-end Server: Apache 2.2.22 (mod_ajp to back-end via Balancer setup)
> Back-end App Server:  Tomcat 6.0.24 (AJP & HTTP connectors, no executor)
> Java -version output:
>    java version "1.6.0_20"
>    OpenJDK Runtime Environment (IcedTea6 1.9.13)
> (6b20-1.9.13-0ubuntu1~10.04.1)
>    OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)
>
>
> Thanks,
> Kyle Harper
>
> (Ignore the stupid privacy message below... automated by mail server)
>
> This communication and any attachments are confidential, protected by Communications
Privacy Act 18 USCS ยง 2510, solely for the use of the intended recipient, and may contain
legally privileged material. If you are not the intended recipient, please return or destroy
it immediately. Thank you.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@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