一胳螟、線程池優(yōu)化
maxConnections? -- 最大連接數(shù)
1蚂蕴、受服務(wù)器內(nèi)核影響,linux 通過 ulimit -a 查看服務(wù)目前情況
open files = 1024? (保守?cái)?shù)值)調(diào)整這個(gè)數(shù)值??
vi /etc/security/limits.conf
在文件下面添加配置?
* soft? ? ?nofiles? ? ? ? 65535
* hard? ? nofiles? ? ? ? 65535
2、添加maxConntions的配置
? ? 考慮:①對(duì)CPU要求更高(計(jì)算量較大)建議對(duì)這屬性配置不要太大,過大時(shí)會(huì)對(duì)CPU產(chǎn)生競爭馁启,會(huì)影響計(jì)算效率(如大數(shù)據(jù)相關(guān))
? ? ? ? ? ? ? ?②對(duì)IO要求比較大 正常訪問數(shù)據(jù)庫,跑邏輯程序芍秆,對(duì)CPU要求不是特別高的時(shí)候惯疙,服務(wù)器建議配置3000左右(64G內(nèi)存,32核CPU)妖啥,實(shí)際2300-2700左右霉颠。(配置后建議做壓測,根據(jù)實(shí)際情況微調(diào))
? ? ? ? ? ? ? ?③配置的位置在:server.xml? -> connector
修改前:
<Connector port="8080" protocol="HTTP/1.1"
? ? ? ? ? ? ? ?connectionTimeout="20000"
? ? ? ? ? ? ? ?redirectPort="8443" />
修改后:
<Connector port="8080" protocol="HTTP/1.1"
? ? ? ? ? ? ? ?maxConnections=”3000“
? ? ? ? ? ? ? ?connectionTimeout="20000"
? ? ? ? ? ? ? ?redirectPort="8443" />
maxThreads -- 最大線程數(shù)
默認(rèn)值是200
推薦配置500-700(1000相當(dāng)于我們對(duì)處理能力要求很高)
修改后
<Connector port="8080" protocol="HTTP/1.1"
? ? ? ? ? ? ? ?maxConnections=”3000“
? ? ? ? ? ? ? ?maxThreads=“500”
? ? ? ? ? ? ? ?connectionTimeout="20000"
? ? ? ? ? ? ? ?redirectPort="8443" />
acceptCount -- 最大排隊(duì)等待數(shù)
在服務(wù)器線程不夠用時(shí)荆虱,會(huì)生成一個(gè)請(qǐng)求隊(duì)列蒿偎,請(qǐng)求隊(duì)列的最大隊(duì)列數(shù)量就是accptCount
Tomcat最大可以處理的線程數(shù)量=maxThreads+acceptCount
推薦比maxThread持平或略小
修改后
<Connector port="8080" protocol="HTTP/1.1"
? ? ? ? ? ? ? ?maxConnections=”3000“
? ? ? ? ? ? ? ?maxThreads=“500”
? ? ? ? ? ? ? ?acceptCount="500"
? ? ? ? ? ? ? ?connectionTimeout="20000"
? ? ? ? ? ? ? ?redirectPort="8443" />