1. 程式人生 > >親們,你們的tomcat併發能到多少?

親們,你們的tomcat併發能到多少?

配置:Intel Xeon E5 2.4G*6核,16G記憶體,Redhat Linux X64,jdk 7(server),tomcat 8.9

改了tomcat 記憶體配置,開啟了nio+epoll,結果仍不好看。。。

vi bin/catalina.sh

CATALINA_OPTS='-Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.EPollSelectorProvider'
JAVA_OPTS= -Xms800M -Xmx1500M -XX:PermSize=128M -XX:MaxPermSize=300M

vi conf/server.xml

<Connector port="7080" protocol="org.apache.coyote.http11.Http11NioProtocol"
               connectionTimeout="20000"
               redirectPort="7443" 
               acceptorThreadCount="6"
               acceptCount="800"
               maxThreads="400"
               compression="on"
               compressionMinSize="2048"
               noCompressionUserAgents="gozilla,traviata" 
               compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain"/>

採用jfinal+beetl模板,apache ab壓力測試結果:

D:\tools\Apache2.2\bin>ab -n 1000 -c 50 http://192.168.xx.xxx:7080/jfinalBeetl
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.xx.xxx (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        Apache-Coyote/1.1
Server Hostname:        192.168.xx.xxx
Server Port:            7080

Document Path:          /jfinalBeetl
Document Length:        327 bytes

Concurrency Level:      50
Time taken for tests:   0.656 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Non-2xx responses:      1000
Total transferred:      146000 bytes
HTML transferred:       0 bytes
Requests per second:    1523.81 [#/sec] (mean)
Time per request:       32.813 [ms] (mean)
Time per request:       0.656 [ms] (mean, across all concurrent requests)
Transfer rate:          217.26 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   2.6      0      16
Processing:     0   32   6.3     31      47
Waiting:        0   20  11.2     16      47
Total:          0   32   6.4     31      47

Percentage of the requests served within a certain time (ms)
  50%     31
  66%     31
  75%     31
  80%     31
  90%     47
  95%     47
  98%     47
  99%     47
 100%     47 (longest request)


未採用beetl,apache ab測試結果:

D:\tools\Apache2.2\bin>ab -n 1000 -c 50 http://192.168.xx.xxx:7080/Root
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.xx.xxx (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        Apache-Coyote/1.1
Server Hostname:        192.168.xx.xxx
Server Port:            7080

Document Path:          /Root
Document Length:        11430 bytes

Concurrency Level:      50
Time taken for tests:   1.297 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      11571000 bytes
HTML transferred:       11430000 bytes
Requests per second:    771.08 [#/sec] (mean)
Time per request:       64.844 [ms] (mean)
Time per request:       1.297 [ms] (mean, across all concurrent requests)
Transfer rate:          8713.10 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   4.1      0      16
Processing:    16   62   9.7     63      94
Waiting:        0   29  18.1     31      78
Total:         16   63   9.5     63      94

Percentage of the requests served within a certain time (ms)
  50%     63
  66%     63
  75%     63
  80%     63
  90%     78
  95%     78
  98%     78
  99%     78
 100%     94 (longest request)


麻,再改進一下,估計能到2000多,曾聽某網友說,調優後的tomcat專案能到3000,不知道是怎麼做的。。。

哪位親給說說。。。

以下由 明月照大江網友提供:

我看了一下,tomcat給的幾個引數,你先別忙著上叢集,試試這些,tomcat8
1.Executor 配置
1.1 maxThreads ,預設是200,把這個設定這個數值,可以再高一些。400,800都試試。會有瓶頸。
2.HTTP Connector 設定
2.1 acceptCount 預設是100,調高,翻幾倍試試
2.2 acceptorThreadCount 預設是1,調成CPU執行緒數,比如4核心8執行緒,就調成8.
2.3 maxThreads 預設是200,調高
2.4 processorCache 如果使用servlet3.0,配置到和 maxThread 一樣
任何和緩衝區相關的配置都可以調大。
JVM引數儘量調大,各代配合合適的記憶體回收演算法。
etc
詳見:http://tomcat.apache.org/tomcat-8.0-doc/config/http.html
壓縮選項之類的可以看著來,其他的比如可以把NIO2改成 APR。
以上是根據官網給的配置資訊  “利用豐富的想象力” 得來的答案,沒有經過任何測試。
先榨乾一個tomcat,再上叢集!


以下轉自http://blog.csdn.net/lifetragedy/article/details/7708724:

Tomcat的優化分成兩塊:
Tomcat啟動命令列中的優化引數即JVM優化
Tomcat容器自身引數的優化(這塊很像ApacheHttp Server)

catalina.sh
export JAVA_OPTS=.....
-server: 我不管你什麼理由,只要你的tomcat是執行在生產環境中的,這個引數必須給我加上
–Xmn: 設定年輕代大小為512m。整個堆大小=年輕代大小 + 年老代大小 + 持久代大小。持久代一般固定大小為64m,所以增大年輕代後,將會減小年老代大小。此值對系統性能影響較大,Sun官方推薦配置為整個堆的3/8。
-Xss: 是指設定每個執行緒的堆疊大小。這個就要依據你的程式,看一個執行緒 大約需要佔用多少記憶體,可能會有多少執行緒同時執行等。一般不易設定超過1M