Tomcat max connections for each context

I have several web applications running under the same Tomcat container. Because they all work under the same Tomcat connector (as defined in server.xml), attributes such as maxConnections and maxThreads control the entire container. As a result, a single application can consume all available Tomcat threads, starving other thread applications and making them immune. I would like to be able to determine the maximum HTTP flows based on each context so that this becomes impossible.

Here is what I have tried so far:

  • Create a custom filter in the application that monitors the current number of threads and limits additional connections. (Got a filter here: How to set a limit on the number of simultaneous requests in a servlet? ). I'm not sure I like this solution because it is not fully functional (support for attributes such as acceptCount, maxConnections, maxThreads and minSpareThreads), because Tomcat provides a container by default; and adding in functions feels like I'm trying to create something that already exists in Tomcat.
  • Create a separate Tomcat connector in the server.xml file for each context. This has a few issues. For example, a separate port is required for each connector; this means that i will have to consider this in my apache configuration. Secondly, I plan to regularly add additional webapps; this means a configuration change followed by a restart of tomcat, which damages the clients.

Has anyone else come across something like this? I feel that there must be a workflow supported by Tomcat to accomplish what I need.

+4
source share
1 answer

, Tomcat: http://tomcat.apache.org/tomcat-9.0-doc/config/valve.html#Semaphore_Valve ( Tomcat 9 , Tomcat 6). , :

  • (Untested) Host server.xml.
  • () [XML ] [context-name] [tomcat-home]/conf/Catalina/localhost , Context.

, , . , , , .

:
, SemaphoreValve , Tomcat , . , , . context.xml Tomcat/conf :

<Valve className="org.apache.catalina.valves.SemaphoreValve" concurrency="10" fairness="true" />

Mark Thomas Apache .

+1

Source: https://habr.com/ru/post/1657805/


All Articles