tomcat 優化到每秒並發1000


tomcat並發線程數能達到多少? 答:tomcat 優化到每秒並發1000,需要以下優化:

一、優化tomcat中的配置(包括tomcat APR(Apache Portable Runtime)優化-性能比純java的強);

二、使用linux系統 : 64位的CPU + 64位的Linux操作系統,再配上64位的JDK,齊活了, 那性能真不是蓋的!

備注: Tomcat本身一般不會成為瓶頸,應用或DB操作,這些才是重點

        用windows的話,著名的MaxUserPort和TcpTimedWaitDelay得先調,不然沒法對比,就這個性能也不是特別高。

        在linux上的默認配置,1K並發可以很輕松的完成。

 

 

 

測試腳本:

1、第一步: 優化配置tomcat

 (1)server.xml:
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="2000" minSpareThreads="1000"/>
   

    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="2000"
               redirectPort="8443"  enableLookups="false"
      acceptCount="5000" maxThreads="2000"/>

(2)catalina.bat:

    set JAVA_OPTS=-Xms1400m -Xmx1400m -Djava.awt.headless=true

2、第二步:寫個index.jsp(除了下面這些代碼,還有200行html代碼,沒有一個圖片)

<%
for(int i=0;i<1000;i++){
   request.setAttribute("key_"+i,"value_"+i);    
}


for(int i=0;i<100;i++){
   request.getSession().setAttribute("key_"+i,"value_"+i);    
}
%>
<br />
<%=request.getSession().getAttribute("key_0")%>
<%=request.getSession().getAttribute("key_0")%>
<%=request.getSession().getAttribute("key_0")%>
<%=request.getSession().getAttribute("key_0")%>
<%=request.getSession().getAttribute("key_0")%>
<%=request.getSession().getAttribute("key_0")%>

3、第三步:啟動tomcat,使用apache ab命令進行並發測試:

          D:\Apache2.2\bin>ab -n 10000 -c 1000 http://127.0.0.1/index.jsp   

ab命令會顯示測試出的結果,這樣就可以測試出tomcat的並發能力。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM