日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

tomcat如何增大并发_Tomcat 7最大并发连接数的正确修改方法

發(fā)布時間:2024/10/6 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 tomcat如何增大并发_Tomcat 7最大并发连接数的正确修改方法 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

轉(zhuǎn)自:http://www.linuxidc.com/Linux/2013-09/90332.htm

這是個很簡單的問題,但是搜了一圈,發(fā)現(xiàn)大家都寫錯了。所以這里總結(jié)一下:

幾乎所有的中文網(wǎng)頁都介紹,要修改Tomcat的默認最大并發(fā)連接數(shù),應該進行如下設(shè)置(實際上這些步驟是錯誤的):

--------------------------------------------

在tomcat配置文件server.xml中的配置中,和連接數(shù)相關(guān)的參數(shù)有:

minProcessors:最小空閑連接線程數(shù),用于提高系統(tǒng)處理性能,默認值為10

maxProcessors:最大連接線程數(shù),即:并發(fā)處理的最大請求數(shù),默認值為75

acceptCount:允許的最大連接數(shù),應大于等于maxProcessors,默認值為100

enableLookups:是否反查域名,取值為:true或false。為了提高處理能力,應設(shè)置為false

connectionTimeout:網(wǎng)絡(luò)連接超時,單位:毫秒。設(shè)置為0表示永不超時,這樣設(shè)置有隱患的。通常可設(shè)置為30000毫秒。

其中和最大連接數(shù)相關(guān)的參數(shù)為maxProcessors和acceptCount。如果要加大并發(fā)連接數(shù),應同時加大這兩個參數(shù)。

web server允許的最大連接數(shù)還受制于操作系統(tǒng)的內(nèi)核參數(shù)設(shè)置,通常Windows是2000個左右,Linux是1000個左右。Unix中如何設(shè)置這些參數(shù),請參閱Unix常用監(jiān)控和管理命令

具體的配置信息:

Java代碼

minProcessors="5" maxProcessors="75" enableLookups="true" redirectPort="8443"

acceptCount="100" debug="0" connectionTimeout="20000 " useURIValidationHack="false"

protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>

--------------------------------------------

但是我仔細查了一圈,發(fā)現(xiàn)這個說法只是以訛傳訛,并不適用于Tomcat 5.5以上的版本。這里先教大家怎么去查Tomcat的官網(wǎng):

首先,在這里:http://tomcat.apache.org/?我們點擊左側(cè)導航欄中“Documentation”下的Tomcat 7.0,進入到這個鏈接中:http://tomcat.apache.org/tomcat-7.0-doc/index.html?,詳細的信息我們不用都看,在左側(cè)導航欄中有一個鏈接Configuration,我們點進去之后,再點擊其左側(cè)導航欄中connector一項的HTTP,就進入到HTTP連接數(shù)及其他相關(guān)屬性的設(shè)置頁面了。在這里(http://tomcat.apache.org/tomcat-7.0-doc/config/http.html)我們可以看到,在Connector的屬性配置中,壓根就沒有maxProcessors等的設(shè)置選項。其中這句話已經(jīng)介紹得很清楚:

If more simultaneous requests are received than can be handled by the currently available request processing threads, additional threads will be created up to the configured maximum (the value of the maxThreads attribute). If still more simultaneous requests are received, they are stacked up inside the server socket created by the Connector, up to the configured maximum (the value of the acceptCount attribute).

所以我們需要設(shè)置的是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,要調(diào)整Tomcat的默認最大連接數(shù),可以增加這兩個屬性的值,并且使acceptCount大于等于maxThreads:

connectionTimeout="20000"

redirectPort="8443" acceptCount="500" maxThreads="400" />

今天就記錄這么多,希望大家以后在轉(zhuǎn)載別人的經(jīng)驗時更用心些,不要老出現(xiàn)上面那些以訛傳訛的情況。也希望能對有些朋友起到幫助。

相關(guān)閱讀:

實例詳解Tomcat組件安裝+Nginx反向代理Tomcat+Apache使用mod_jk和mod_proxy反向代理和負載均衡?http://www.linuxidc.com/Linux/2013-06/85290.htm

總結(jié)

以上是生活随笔為你收集整理的tomcat如何增大并发_Tomcat 7最大并发连接数的正确修改方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。