tomcat 优化到每秒并发1000

现在系统部署只能达到240+ , tomcat + apache 也只能到 900 + ,看到robbin的发帖能达到1000 ,不知道该如何配置,特来请教:
http://www.iteye.com/post/370111?page=8
robbin 写道
既然你用tomcat4都可以达到并发600,那tomcat5.5在同样环境下经过调优完全可以达到1000,看来问题还是在于你们tomcat没有配置好。

附带环境配置如下:

环境配置如下: (jdk没有用 -server)

Java代码 复制代码
  1. windows2003企业版sp2
  2. Intel(R)Xeon(R)4CPU5130@2.0GHz4.00GB内存
  3. apache_2.2.8-win32-x86
  4. mod_jk-apache-2.0.59
  5. jdk-1_5_0_14-windows-i586-p.exe-client
  6. Tomcat-6.0.16+apr

server.xml

Xml代码 复制代码
  1. <Executorname="tomcatThreadPool"namePrefix="catalina-exec-"maxThreads="2000"minSpareThreads="1000"/>
  2. <Connectorport="8080"protocol="HTTP/1.1"
  3. connectionTimeout="2000"
  4. redirectPort="8443"enableLookups="false"
  5. acceptCount="5000"maxThreads="2000"/>

catalina.bat

Java代码 复制代码
  1. setJAVA_OPTS=-Xms1400m-Xmx1400m-Djava.awt.headless=true

index.jsp (除了下面这些代码,还有200行html代码,没有一个图片)

Java代码 复制代码
  1. <%
  2. for(inti=0;i<1000;i++){
  3. request.setAttribute("key_"+i,"value_"+i);
  4. }
  5. for(inti=0;i<100;i++){
  6. request.getSession().setAttribute("key_"+i,"value_"+i);
  7. }
  8. %>
  9. <br/>
  10. <%=request.getSession().getAttribute("key_0")%>
  11. <%=request.getSession().getAttribute("key_0")%>
  12. <%=request.getSession().getAttribute("key_0")%>
  13. <%=request.getSession().getAttribute("key_0")%>
  14. <%=request.getSession().getAttribute("key_0")%>
  15. <%=request.getSession().getAttribute("key_0")%>

tomat 启动信息如下:

Java代码 复制代码
  1. 2008-5-617:54:52org.apache.catalina.core.AprLifecycleListenerinit
  2. 信息:LoadedAPRbasedApacheTomcatNativelibrary1.1.10.
  3. 2008-5-617:54:52org.apache.catalina.core.AprLifecycleListenerinit
  4. 信息:APRcapabilities:IPv6[false],sendfile[true],acceptfilters[false],r
  5. andom[true].
  6. 2008-5-617:54:52org.apache.coyote.http11.Http11AprProtocolinit
  7. 信息:InitializingCoyoteHTTP/1.1onhttp-8080
  8. 2008-5-617:54:52org.apache.coyote.ajp.AjpAprProtocolinit
  9. 信息:InitializingCoyoteAJP/1.3onajp-30008
  10. 2008-5-617:54:52org.apache.catalina.startup.Catalinaload
  11. 信息:Initializationprocessedin973ms
  12. 2008-5-617:54:52org.apache.catalina.core.StandardServicestart
  13. 信息:StartingserviceCatalina
  14. 2008-5-617:54:52org.apache.catalina.core.StandardEnginestart
  15. 信息:StartingServletEngine:ApacheTomcat/6.0.16
  16. 2008-5-617:54:52org.apache.coyote.http11.Http11AprProtocolstart
  17. 信息:StartingCoyoteHTTP/1.1onhttp-8080
  18. 2008-5-617:54:53org.apache.coyote.ajp.AjpAprProtocolstart
  19. 信息:StartingCoyoteAJP/1.3onajp-30008
  20. 2008-5-617:54:53org.apache.catalina.startup.Catalinastart
  21. 信息:Serverstartupin310ms

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

下面是测试结果:

tomcat + apache 测试结果:

Java代码 复制代码
  1. D:\Apache2.2\bin>ab-n10000-c800http://127.0.0.1/index.jsp
  2. ServerSoftware:Apache/2.2.4
  3. ServerHostname:127.0.0.1
  4. ServerPort:80
  5. DocumentPath:/index.jsp
  6. DocumentLength:41078bytes
  7. ConcurrencyLevel:800
  8. Timetakenfortests:34.46875seconds
  9. Completerequests:10000
  10. Failedrequests:0
  11. Writeerrors:0
  12. Totaltransferred:413090000bytes
  13. HTMLtransferred:410780000bytes
  14. Requestspersecond:293.71[#/sec](mean)
  15. Timeperrequest:2723.750[ms](mean)
  16. Timeperrequest:3.405[ms](mean,acrossallconcurrentrequests)
  17. Transferrate:11848.61[Kbytes/sec]received
  18. ConnectionTimes(ms)
  19. minmean[+/-sd]medianmax
  20. Connect:001.8015
  21. Processing:1520343425.192123265
  22. Waiting:020253423.892123250
  23. Total:1520343425.192123265
  24. Percentageoftherequestsservedwithinacertaintime(ms)
  25. 50%921
  26. 66%1343
  27. 75%1656
  28. 80%1875
  29. 90%5078
  30. 95%9421
  31. 98%15828
  32. 99%18171
  33. 100%23265(longestrequest)
  34. D:\Apache2.2\bin>ab-n10000-c1000http://127.0.0.1/index.jsp
  35. ServerSoftware:Apache/2.2.4
  36. ServerHostname:127.0.0.1
  37. ServerPort:80
  38. DocumentPath:/index.jsp
  39. DocumentLength:323bytes
  40. ConcurrencyLevel:1000
  41. Timetakenfortests:24.265625seconds
  42. Completerequests:10000
  43. Failedrequests:3953
  44. (Connect:0,Length:3953,Exceptions:0)
  45. Writeerrors:0
  46. Non-2xxresponses:8686
  47. Totaltransferred:58651479bytes
  48. HTMLtransferred:56541921bytes
  49. Requestspersecond:412.11[#/sec](mean)
  50. Timeperrequest:2426.563[ms](mean)
  51. Timeperrequest:2.427[ms](mean,acrossallconcurrentrequests)
  52. Transferrate:2360.38[Kbytes/sec]received
  53. ConnectionTimes(ms)
  54. minmean[+/-sd]medianmax
  55. Connect:001.7015
  56. Processing:015734416.43123984
  57. Waiting:015634402.53123984
  58. Total:015734416.53123984
  59. Percentageoftherequestsservedwithinacertaintime(ms)
  60. 50%31
  61. 66%62
  62. 75%62
  63. 80%62
  64. 90%7031
  65. 95%13234
  66. 98%18218
  67. 99%19859
  68. 100%23984(longestrequest)

tomcat 单独测试结果 (250并发会经常失败,200比较正常,偶尔有少量错误):

Java代码 复制代码
  1. D:\Apache2.2\bin>ab-n1000-c250http://127.0.0.1:8080/index.jsp
  2. ThisisApacheBench,Version2.0.40-dev<$Revision:1.146$>apache-2.0
  3. Copyright1996AdamTwiss,ZeusTechnologyLtd,http://www.zeustech.net/
  4. Copyright2006TheApacheSoftwareFoundation,http://www.apache.org/
  5. Benchmarking127.0.0.1(bepatient)
  6. Completed100requests
  7. Sendrequestfailed!
  8. Sendrequestfailed!
  9. Sendrequestfailed!
  10. Sendrequestfailed!
  11. Sendrequestfailed!
  12. Completed200requests
  13. Sendrequestfailed!
  14. apr_socket_recv:远程主机强迫关闭了一个现有的连接。(730054)
  15. Totalof223requestscompleted
  16. D:\Apache2.2\bin>ab-n1000-c250http://127.0.0.1:8080/index.jsp
  17. ServerSoftware:Apache-Coyote/1.1
  18. ServerHostname:127.0.0.1
  19. ServerPort:8080
  20. DocumentPath:/index.jsp
  21. DocumentLength:41078bytes
  22. ConcurrencyLevel:250
  23. Timetakenfortests:2.390625seconds
  24. Completerequests:1000
  25. Failedrequests:0
  26. Writeerrors:0
  27. Totaltransferred:41292000bytes
  28. HTMLtransferred:41078000bytes
  29. Requestspersecond:418.30[#/sec](mean)
  30. Timeperrequest:597.656[ms](mean)
  31. Timeperrequest:2.391[ms](mean,acrossallconcurrentrequests)
  32. Transferrate:16867.56[Kbytes/sec]received
  33. ConnectionTimes(ms)
  34. minmean[+/-sd]medianmax
  35. Connect:001.9015
  36. Processing:109575314.15151218
  37. Waiting:62550315.04531156
  38. Total:109575314.15151218
  39. Percentageoftherequestsservedwithinacertaintime(ms)
  40. 50%515
  41. 66%609
  42. 75%921
  43. 80%1031
  44. 90%1062
  45. 95%1125
  46. 98%1140
  47. 99%1140
  48. 100%1218(longestrequest)

单独测试tomcat基本上只能达到240+左右的并发,tomcat+apache 900+并发,如果是静态页面tomcat并发1000+没有任何问题。

tomcat基本上都保持在 20% - 45% 之间 , 内存在 80M -- 600M +之间 ,根据并发和请求的大小,内存的变法比较明显,cpu基本保存在这里,apache占用的cpu基本上是在 15% - 40%。

因为JRockit收费,所以就没有测试。(主要是真实部署的时候会采用这些配置,收费的公司目前也不会购买!^_^)

你可能感兴趣的:(apache,tomcat,c,jsp,windows)