Spring Gateway 和 Zuul 1性能比较

https://www.jianshu.com/p/ce88ddeeb9cd

spring gateway使用基于netty异步io;
zuul 1使用servlet 3,每个请求一个线程,同步Servlet,多线程阻塞模型。
而spring貌似不想在支持zuul 2了。issue

简单demo,get请求转发到http://httpbin.org/get,测试结果如下

ab -c 10 -n 1000

  • zuul 1结果

 

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:   206  300 217.1    215    2254
Waiting:      206  300 217.0    214    2254
Total:        206  300 217.1    215    2254

Percentage of the requests served within a certain time (ms)
  50%    215
  66%    221
  75%    227
  80%    247
  90%    582
  95%    685
  98%    905
  99%   1114
 100%   2254 (longest request)
  • spring gateway结果

 

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:   193  281 189.4    200    2114
Waiting:      193  281 189.4    200    2113
Total:        193  281 189.4    201    2114

Percentage of the requests served within a certain time (ms)
  50%    201
  66%    206
  75%    217
  80%    233
  90%    593
  95%    653
  98%    853
  99%   1029
 100%   2114 (longest request)

ab -c 50 -n 1000

  • zuul 1结果

 

Connection Times (ms)
             min  mean[+/-sd] median   max
Connect:        0    0   0.6      0       4
Processing:   220  696 322.9    631    2222
Waiting:      220  695 322.8    630    2222
Total:        220  696 322.9    631    2224

Percentage of the requests served within a certain time (ms)
 50%    631
 66%    675
 75%    736
 80%    861
 90%   1101
 95%   1499
 98%   1620
 99%   1853
100%   2224 (longest request)
  • spring gateway 结果

 

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.5      0       3
Processing:   193  274 185.6    201    1848
Waiting:      193  274 185.6    201    1848
Total:        193  274 185.7    201    1849

Percentage of the requests served within a certain time (ms)
  50%    201
  66%    205
  75%    212
  80%    223
  90%    610
  95%    661
  98%    776
  99%   1024
 100%   1849 (longest request)

总结

在低并发的情况下,zuul 1spring gateway差距并不大,
在高并发情况下,差距会很明显。
这也就是异步io和多线程阻塞模型的区别。

参考http://blog.didispace.com/api-gateway-Zuul-1-zuul-2-how-to-choose/



作者:tenlee
链接:https://www.jianshu.com/p/ce88ddeeb9cd
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

你可能感兴趣的:(springcloud)