Netflix Zuul vs OpenResty

Spring Cloud Netflix的组件中Zuul作为一个网关服务,提供了动态路由、监控、安全和弹性伸缩这些服务。由于Zuul是由Java编写的,我一直有些怀疑它性能上的表现,所以做了几组Zuul和基于nginxOpenResty的测试对比。

框架版本:

  • Spring Cloud Zuul: 1.1.0.RELEASE
  • OpenResty : 1.11.2.2

我用Spring MVC写一个非常普通的REST请求:

@RequestMapping("/hello")
public String hello() {
    return "world";
}

然后用ZuulOpenResty都对其进行反向代理(Zuul使用5555端口,OpenResty使用80端口),使用wrk对其分别进行测试。

第一轮:

➜  ~ wrk -t 10 -c 50 -d 10s http://localhost:5555/api/test/hello
Running 10s test @ http://localhost:5555/api/test/hello
  10 threads and 50 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    33.95ms   43.06ms 599.09ms   89.81%
    Req/Sec   210.68     73.11   460.00     68.00%
  21045 requests in 10.04s, 4.12MB read
Requests/sec:   2095.30
Transfer/sec:    419.61KB
➜  ~ wrk -t 10 -c 50 -d 10s http://localhost/test/hello
Running 10s test @ http://localhost/test/hello
  10 threads and 50 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    24.52ms    5.87ms  89.64ms   87.58%
    Req/Sec   202.87     35.50   297.00     75.25%
  16222 requests in 10.11s, 2.66MB read
Requests/sec:   1604.71
Transfer/sec:    269.47KB

第二轮:

➜  ~ wrk -t 10 -c 100 -d 10s http://localhost:5555/api/test/hello
Running 10s test @ http://localhost:5555/api/test/hello
  10 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    34.50ms   23.16ms 335.87ms   88.20%
    Req/Sec   313.05     69.63   590.00     70.81%
  31196 requests in 10.04s, 6.10MB read
Requests/sec:   3107.57
Transfer/sec:    622.49KB
➜  ~ wrk -t 10 -c 100 -d 10s http://localhost/test/hello
Running 10s test @ http://localhost/test/hello
  10 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    41.88ms    4.91ms  69.37ms   83.79%
    Req/Sec   236.47     29.29   386.00     69.42%
  16332 requests in 10.09s, 2.68MB read
Requests/sec:   1619.00
Transfer/sec:    271.89KB

第三轮(这组先跑的OpenResty):

➜  ~ wrk -t 10 -c 100 -d 10s http://localhost/test/hello
Running 10s test @ http://localhost/test/hello
  10 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    42.36ms    8.17ms 111.17ms   88.12%
    Req/Sec   232.84     41.45   303.00     72.86%
  16328 requests in 10.10s, 2.68MB read
Requests/sec:   1617.40
Transfer/sec:    271.63KB
➜  ~ wrk -t 10 -c 100 -d 10s http://localhost:5555/api/test/hello
Running 10s test @ http://localhost:5555/api/test/hello
  10 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    29.35ms   22.16ms 367.66ms   90.37%
    Req/Sec   376.03     73.41   696.00     72.10%
  37504 requests in 10.03s, 7.33MB read
Requests/sec:   3737.35
Transfer/sec:    748.47KB

测试结果有些出乎意料,从以上数据中可以看出,Zuul在JVM预热结束之后,性能居然还优于OpenResty

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,837评论 18 139
  • Spring Boot 参考指南 介绍 转载自:https://www.gitbook.com/book/qbgb...
    毛宇鹏阅读 46,926评论 6 342
  • zuul 上传文件 在user-service中定义一个上传接口: 配置文件配置如下: 在user-service...
    二月_春风阅读 10,354评论 2 8
  • 本篇文章内容简单,但是没有前面的基础是很难理解的,所以推荐看Spring Cloud系列的其他四篇文章,代码实现简...
    Chinesszz阅读 3,370评论 1 6
  • 天气变得好冷 来往的情侣相偎相依 我的左手握着右手 想着你掌心的温暖 要是你在,该有多好 过道的银杏黄了 片片凋落...
    余子欢阅读 347评论 4 1