天天看點

Tomcat配置檔案server.xml中connector的參數minSpareThreads和maxSpareThreads

在網上看到很多tomcat6.0的優化文章中,都提到了在server.xml中的connector标簽中,加上[b]minSpareThreads[/b] 和 [b]maxSpareThreads[/b]屬性,可是我到了tomcat的官網上去看文檔,發現tomcat6.0中connector标簽根本沒有這兩個屬性,在tomcat5.5中才有。

tomcat5.5的文檔連接配接:[u]http://tomcat.apache.org/tomcat-5.5-doc/config/http.html[/u]

裡面原文是這樣介紹這兩個屬性的:

maxSpareThreads:The maximum number of unused request processing threads that will be allowed to exist until the thread pool starts stopping the unnecessary threads. The default value is 50.

自己翻譯一下,不知道是否正确:

maxSpareThreads:直到線程池開始停止不需要的線程時,允許存在空閑請求處理線程的最大數量。預設值50.

我的了解是這樣的,當空閑的線程超過maxSpareThreads時,tomcat就關閉超出這個數值的線程。

網上的說法都是複制粘貼的,如下:

maxSpareThreads:最大備用線程數,一旦建立的線程超過這個值,Tomcat就會關閉不再需要的socket線程。

我覺得和我的了解是不同的。

再說,minSpareThreads。

minSpareThreads:The number of request processing threads that will be created when this Connector is first started. The connector will also make sure it has the specified number of idle processing threads available. This attribute should be set to a value smaller than that set for maxThreads. The default value is 4.

大概意思就是:初始會建立的線程數,并且確定最少會有這麼多個線程數可用,并且設定的值要比參數[b]maxThreads[/b]大。預設值是4.

以上是tomcat5.5的文檔寫的内容,到了tomcat6.0,文檔裡面根本就沒有介紹這兩個參數,難道是寫文檔的人落了這兩個參數沒有寫?文檔位址如下:

[u]http://tomcat.apache.org/tomcat-6.0-doc/config/http.html[/u]

可是網上都說tomcat6.0優化要寫這兩個參數,是為什麼???

到了tomcat7.0的時候,隻有minSpareThreads了。文檔位址如下:

[u]http://tomcat.apache.org/tomcat-7.0-doc/config/http.html[/u]

tomcat7.0對minSpareThreads的介紹也發生了變化:

minSpareThreads:The minimum number of threads always kept running. If not specified, the default of 10 is used.

大家可以看到,預設值是10個了。

是以大家可否分享一下各自的知識,tomcat6.0究竟是有沒有這兩個參數呢?