OpenAPI (Kong) Benchmark

测试用API基准性能测试

API编写

为了测试API Gateway的性能,我们首先要有一个测试用API。
用Go语言,采用基于fasthttp的iris框架,编写一个简单的HelloWorld Server。如下所示:

 
 
  1. package main
  2. import "github.com/kataras/iris"
  3. func main() {
  4. api := iris.New()
  5. api.Get("/hi", hi)
  6. api.Listen(":8080")
  7. }
  8. func hi(ctx *iris.Context){
  9. ctx.Write("Hi %s", "iris")
  10. }
测试API是否可用
 
 
  1. $ curl http://127.0.0.1:8080/hi
  2. Hi iris
Bench测试用API
 
 
  1. 并发 RPS TPR
  2. 1 21391.66 0.047
  3. 2 29864.03 0.067
  4. 3 63258.51 0.047
  5. 4 73325.61 0.055
  6. 5 80241.88 0.062
  7. 8 99025.29 0.081
  8. 10 105148.38 0.095
  9. 16 99378.09 0.161
  10. 20 99064.04 0.202
  11. 25 96601.46 0.259
  12. 30 94350.84 0.318
  13. 32 97307.03 0.329
  14. 40 93983.53 0.426
  15. 50 95480.85 0.524
  16. 64 94770.72 0.675
  17. 80 90437.65 0.885
  18. 100 93304.23 1.072
  19. 120 91837.84 1.307
  20. 128 91585.78 1.398
  21. 150 92307.99 1.625
  22. 180 92827.5 1.939
  23. 200 93157.63 2.147
  24. 500 93920.95 5.324
  25. 1000 90560.25 11.042
  26. 2000 73470.44 27.222
  27. 5000 72345.1 69.113
  28. 10000 70525.77 141.792

结论是,在合理的并发数下,QPS基本可以稳定在9W左右。最佳并发数为10。
对于测试,该API不可能成为瓶颈。

单实例API网关

注册为OpenAPI
 
 
  1. curl -X POST http://localhost:8888/apis/ \
  2. -d "name=overseas_index" \
  3. -d "upstream_url=http://10.182.20.100:8080/" \
  4. -d "request_path=/test" \
  5. -d "strip_request_path=true"
  6. {"upstream_url":"http:\/\/10.182.20.100:8080\/","request_path":"\/test","id":"36cc77c7-89cd-49d3-b153-e79c632ccc44","created_at":1471509004000,"preserve_host":false,"strip_request_path":true,"name":"overseas_index"}
测试OpenAPI连通情况
 
 
  1. $ curl http://127.0.0.1/test/hi
  2. Hi iris
从同机房通过API Gateway进行测试:
 
 
  1. c n rps tpr
  2. 50 100000 13780.78 3.628
  3. 100 100000 16499.59 6.061
  4. 200 100000 15778.13 12.676
  5. 500 100000 14109.51 35.437
使用OpenAPI,添加key-auth权限认证,ACL,从外网接口访问:
 
 
  1. c n rps tpr
  2. 50 100000 14006.29 3.570
  3. 100 100000 16087.16 6.216
  4. 200 100000 16033.10 12.474
  5. 500 100000 14080.34 35.511

(3 Nginx Node, 3x24 EchoServer)

在没有进行任何优化的条件下,峰值约16000 QPS。应对目前Cplus需求非常充裕。但对于DMP还需要进一步优化。优化空间很大。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值