1. 程式人生 > >springcloud與dubbo的效能對比

springcloud與dubbo的效能對比

 在長期使用dubbo的團隊中推行springcloud確實是個難題,巨大理由之一就是rpc呼叫效率遠遠高於http,故此做一個相關效能測試,所用到的dubbo與spring系均採用官方最新版(dubbo 2.5.7 、springboot 1.5.9 、springcloud edgware)。

springcloud測試程式碼地址 https://github.com/liuchengts/spring-cloud-ts.git

dubbo測試程式碼地址 https://github.com/liuchengts/dubbo-ts.git

測試思路:使用ab工具執行10000個請求併發量為100,多次測試,取最高與最低值計算平均值
測試物件:

       1、dubbo請求:http://192.168.10.138:8082/

   2、cloud直接請求:http://192.168.10.138:3002/

   3、cloudzuul路由請求:http://192.168.10.138:3000/test-comsumer/
測試過程:
  dubbo:
最高效能時期:

AppledeMacBook-Pro:~ apple$ ab -n 10000 -c 100 http://192.168.10.138:8082/

This is ApacheBench, Version 2.3 <$Revision: 1796539 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.10.138 (be patient)

Completed 1000 requests

Completed 2000 requests

Completed 3000 requests

Completed 4000 requests

Completed 5000 requests

Completed 6000 requests

Completed 7000 requests

Completed 8000 requests

Completed 9000 requests

Completed 10000 requests

Finished 10000 requests

Server Software:        

Server Hostname:        192.168.10.138

Server Port:            8082

Document Path:          /

Document Length:        11 bytes

Concurrency Level:      100

Time taken for tests:   2.881 seconds

Complete requests:      10000

Failed requests:        0

Total transferred:      1850000 bytes

HTML transferred:       110000 bytes

Requests per second:    3470.94 [#/sec] (mean)

Time per request:       28.811 [ms] (mean)

Time per request:       0.288 [ms] (mean, across all concurrent requests)

Transfer rate:          627.07 [Kbytes/sec] received

Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        3   12   5.5     11      57

Processing:     7   16   6.1     15      63

Waiting:        7   16   6.0     14      63

Total:         16   28   9.4     26     102

Percentage of the requests served within a certain time (ms)

  50%     26

  66%     28

  75%     30

  80%     31

  90%     36

  95%     44

  98%     65

  99%     70

 100%    102 (longest request)

最低效能時期:

AppledeMacBook-Pro:~ apple$ ab -n 10000 -c 100 http://192.168.10.138:8082/

This is ApacheBench, Version 2.3 <$Revision: 1796539 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.10.138 (be patient)

Completed 1000 requests

Completed 2000 requests

Completed 3000 requests

Completed 4000 requests

Completed 5000 requests

Completed 6000 requests

Completed 7000 requests

Completed 8000 requests

Completed 9000 requests

Completed 10000 requests

Finished 10000 requests

Server Software:        

Server Hostname:        192.168.10.138

Server Port:            8082

Document Path:          /

Document Length:        11 bytes

Concurrency Level:      100

Time taken for tests:   3.064 seconds

Complete requests:      10000

Failed requests:        0

Total transferred:      1850000 bytes

HTML transferred:       110000 bytes

Requests per second:    3264.11 [#/sec] (mean)

Time per request:       30.636 [ms] (mean)

Time per request:       0.306 [ms] (mean, across all concurrent requests)

Transfer rate:          589.71 [Kbytes/sec] received

Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        3   14  31.9     11    1115

Processing:     6   16   8.4     15     209

Waiting:        5   16   8.3     14     209

Total:         11   30  33.5     27    1130

Percentage of the requests served within a certain time (ms)

  50%     27

  66%     29

  75%     30

  80%     31

  90%     35

  95%     46

  98%     72

  99%     88

 100%   1130 (longest request)

dubbo平均響應結果為:
  (0.288+0.306)/2=0.297ms
 
cloud:
最高效能時期:

AppledeMacBook-Pro:~ apple$ ab -n 10000 -c 100 http://192.168.10.138:3002/

This is ApacheBench, Version 2.3 <$Revision: 1796539 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.10.138 (be patient)

Completed 1000 requests

Completed 2000 requests

Completed 3000 requests

Completed 4000 requests

Completed 5000 requests

Completed 6000 requests

Completed 7000 requests

Completed 8000 requests

Completed 9000 requests

Completed 10000 requests

Finished 10000 requests

Server Software:        

Server Hostname:        192.168.10.138

Server Port:            3002

Document Path:          /

Document Length:        33 bytes

Concurrency Level:      100

Time taken for tests:   2.379 seconds

Complete requests:      10000

Failed requests:        0

Total transferred:      2090000 bytes

HTML transferred:       330000 bytes

Requests per second:    4203.69 [#/sec] (mean)

Time per request:       23.789 [ms] (mean)

Time per request:       0.238 [ms] (mean, across all concurrent requests)

Transfer rate:          857.98 [Kbytes/sec] received

Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        4   10   2.1     10      28

Processing:     5   14   2.6     13      33

Waiting:        5   14   2.6     13      33

Total:         15   24   3.1     23      41

Percentage of the requests served within a certain time (ms)

  50%     23

  66%     24

  75%     25

  80%     26

  90%     27

  95%     29

  98%     32

  99%     34

 100%     41 (longest request)

最低效能時期:

AppledeMacBook-Pro:~ apple$ ab -n 10000 -c 100 http://192.168.10.138:3002/

This is ApacheBench, Version 2.3 <$Revision: 1796539 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.10.138 (be patient)

Completed 1000 requests

Completed 2000 requests

Completed 3000 requests

Completed 4000 requests

Completed 5000 requests

Completed 6000 requests

Completed 7000 requests

Completed 8000 requests

Completed 9000 requests

Completed 10000 requests

Finished 10000 requests

Server Software:        

Server Hostname:        192.168.10.138

Server Port:            3002

Document Path:          /

Document Length:        33 bytes

Concurrency Level:      100

Time taken for tests:   3.578 seconds

Complete requests:      10000

Failed requests:        0

Total transferred:      2090000 bytes

HTML transferred:       330000 bytes

Requests per second:    2795.10 [#/sec] (mean)

Time per request:       35.777 [ms] (mean)

Time per request:       0.358 [ms] (mean, across all concurrent requests)

Transfer rate:          570.48 [Kbytes/sec] received

Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        3   15  28.2     10    1242

Processing:     8   20  20.3     14     300

Waiting:        8   19  20.3     14     300

Total:         15   35  41.4     25    1255

Percentage of the requests served within a certain time (ms)

  50%     25

  66%     26

  75%     28

  80%     29

  90%     41

  95%    112

  98%    169

  99%    192

 100%   1255 (longest request)

cloud平均響應結果為:(
0.238+0.358)/2=0.298ms
 
cloud-zuul:
最高效能時期:

AppledeMacBook-Pro:~ apple$ ab -n 10000 -c 100 http://192.168.10.138:3000/test-comsumer/

This is ApacheBench, Version 2.3 <$Revision: 1796539 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.10.138 (be patient)

Completed 1000 requests

Completed 2000 requests

Completed 3000 requests

Completed 4000 requests

Completed 5000 requests

Completed 6000 requests

Completed 7000 requests

Completed 8000 requests

Completed 9000 requests

Completed 10000 requests

Finished 10000 requests

Server Software:        

Server Hostname:        192.168.10.138

Server Port:            3000

Document Path:          /test-comsumer/

Document Length:        118 bytes

Concurrency Level:      100

Time taken for tests:   3.269 seconds

Complete requests:      10000

Failed requests:        0

Non-2xx responses:      10000

Total transferred:      2710000 bytes

HTML transferred:       1180000 bytes

Requests per second:    3059.49 [#/sec] (mean)

Time per request:       32.685 [ms] (mean)

Time per request:       0.327 [ms] (mean, across all concurrent requests)

Transfer rate:          809.69 [Kbytes/sec] received

Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        3   12  71.0      7    1248

Processing:     4   21  15.8     17     220

Waiting:        4   21  15.7     17     220

Total:          8   33  73.0     25    1284

Percentage of the requests served within a certain time (ms)

  50%     25

  66%     30

  75%     33

  80%     36

  90%     43

  95%     50

  98%     61

  99%     84

 100%   1284 (longest request)

最低效能時期:

AppledeMacBook-Pro:~ apple$ ab -n 10000 -c 100 http://192.168.10.138:3000/test-comsumer/

This is ApacheBench, Version 2.3 <$Revision: 1796539 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.10.138 (be patient)

Completed 1000 requests

Completed 2000 requests

Completed 3000 requests

Completed 4000 requests

Completed 5000 requests

Completed 6000 requests

Completed 7000 requests

Completed 8000 requests

Completed 9000 requests

Completed 10000 requests

Finished 10000 requests

Server Software:        

Server Hostname:        192.168.10.138

Server Port:            3000

Document Path:          /test-comsumer/

Document Length:        118 bytes

Concurrency Level:      100

Time taken for tests:   4.796 seconds

Complete requests:      10000

Failed requests:        0

Non-2xx responses:      10000

Total transferred:      2710000 bytes

HTML transferred:       1180000 bytes

Requests per second:    2085.16 [#/sec] (mean)

Time per request:       47.958 [ms] (mean)

Time per request:       0.480 [ms] (mean, across all concurrent requests)

Transfer rate:          551.83 [Kbytes/sec] received

Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        2   20 114.6      7    1292

Processing:     4   28  18.0     25     135

Waiting:        4   27  18.0     24     135

Total:          6   48 118.1     34    1376

Percentage of the requests served within a certain time (ms)

  50%     34

  66%     43

  75%     49

  80%     53

  90%     64

  95%     78

  98%    141

  99%    166

 100%   1376 (longest request)

cloud-zuul
平均響應結果為:(0.480+0.327)/2=0.4035ms
 

發現一個現象:
dubbo的每次測試除去網路波動之外,都表現非常穩定
而cloud在第一次最慢,之後越來越快,連續測試4次以上單次測試效能超過dubbo
cloud-zuul在第一次最慢,之後也表現越來越快,連續4次以上測試 單次效能與dubbo相近,相差在0.02ms內