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

1 Answer 1

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)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.