Embedded Tomcat: how to configure the number of request threads

喜夏-厌秋 提交于 2019-12-11 03:38:14

问题


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:


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)



来源:https://stackoverflow.com/questions/16920221/embedded-tomcat-how-to-configure-the-number-of-request-threads

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!