配置Tomcat線程參數maxThreads、acceptCount

來源:互聯網
上載者:User

標籤:alt   serve   返回   網路連接   lsp   ble   表示   tom   server   

一、配置
Tomcat/conf/server.xml修改配置

<Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"
  connectionTimeout="20000"        
  redirectPort="8443"        
  URIEncoding="UTF-8"        
  minSpareThreads="25"        
  maxSpareThreads="300"        
  maxThreads="500"        
  acceptCount="500"        
  connectionTimeout="30000"        
  enableLookups="false"/>

 二、參數說明

maxIdleTime:最大空閑時間,超過這個空閑時間,且線程數大於minSpareThreads的,都會被回收,預設值1分鐘(60000ms);
minSpareThreads:最小空閑線程數,任何情況都會存活的線程數,即便超過了最大空閑時間,也不會被回收,預設值4;
maxSpareThreads:最大空閑線程數,在最大空閑時間(maxIdleTime)內活躍過,此時空閑,當空閑時間大於maxIdleTime則被回收,小則繼續存活,等待被調度,預設值50;
maxThreads:最大線程數,大並發請求時,tomcat能建立來處理請求的最大線程數,超過則放入請求隊列中進行排隊,預設值為200;
acceptCount:當最大線程數(maxThreads)被使用完時,可以放入請求隊列排隊個數,超過這個數返回connection refused(請求被拒絕),一般設定和maxThreads一樣,不過
這個具體需要根據自己的應用實際訪問峰值和平均值來權衡,預設值為100;connectionTimeout:網路連接逾時,假設設定為0表示永不逾時,這樣設定隱患巨大,通常可設定為30000ms,預設60000ms。

 

 

Windows Tomcat每個進程允許maxThreads(最大線程數)2000

LinuxTomcat每個進程允許maxThreads(最大線程數)1000

 

圖解線程池原理

關於maxThread如何配置,我是參考這位博主寫的這篇博文理解的http://blog.sina.com.cn/s/blog_605f5b4f01012ljj.html

配置Tomcat線程參數maxThreads、acceptCount

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.