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

相关内容

    暂无相关文章