2

In Embedded Tomcat, how can I configure the number of request threads?

I can't seem to get it to work. I tried all of these without success:

  • tomcat.getConnector().setProperty("maxThreads", "20");
  • tomcat.getConnector().setAttribute("maxThreads", "20");
  • tomcat.getConnector().setAttribute("maxThreads", 20);
Axel Fontaine
  • 34,542
  • 16
  • 106
  • 137

1 Answers1

1

If you want embedded tomcat to refuse new connections after 20 connections, you should also set acceptCount attribute. So, below code should work and refuse new connections after 20.

tomcat.getConnector().setAttribute("maxThreads", "20");
tomcat.getConnector().setAttribute("acceptCount", "20");

(check the introduction on http://tomcat.apache.org/tomcat-7.0-doc/config/http.html)

jdiver
  • 2,228
  • 1
  • 19
  • 20