設置 tomcat 請求超時時間 和 最大連接數

可以通過設置tomcat下conf文件夾的server.xml文件,對請求連接數和請求超時時間進行設置。

<Connector port="8080" protocol="HTTP/1.1" 
              connectionTimeout="20000" 
              redirectPort="8443" acceptCount="400" maxThreads="300" />

connectionTimeout以毫秒爲單位,默認設置爲20秒。通過修改該參數,可以修改tomcat的請求超時時間;

關於修改最大併發請求連接數,需要修改maxThreads和acceptCount兩個參數,

其中,maxThreads的介紹如下:

The maximum number of request processing threads to be created by this Connector, which therefore determines the maximum number of simultaneous requests that can be handled. If not specified, this attribute is set to 200. If an executor is associated with this connector, this attribute is ignored as the connector will execute tasks using the executor rather than an internal thread pool.

而acceptCount的介紹爲:

The maximum queue length for incoming connection requests when all possible request processing threads are in use. Any requests received when the queue is full will be refused. The default value is 100.

所以兩者的默認值分別是200和100,要調整Tomcat的默認最大連接數,可以增加這兩個屬性的值,並且使acceptCount大於等於maxThreads

本文轉載自linux社區,作者:qysh123,文章鏈接:http://www.linuxidc.com/Linux/2013-09/90332.htm
並轉於csdn錢塘觀海處,當作記錄

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章