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还需要进一步优化。优化空间很大。

目录
相关文章
|
6月前
|
XML JSON 数据格式
StreamUtil是阿里云OpenAPI提供的一个工具
StreamUtil是阿里云OpenAPI提供的一个工具
88 1
|
1月前
|
JSON 安全 Java
如何基于 Swagger 使用 OpenAPI Generator生成 JMeter 脚本
【2月更文挑战第24天】如何基于 Swagger 使用 OpenAPI Generator生成 JMeter 脚本
35 0
如何基于 Swagger 使用 OpenAPI Generator生成 JMeter 脚本
|
3月前
|
API Go
.NET7 Preview4 之OpenAPI swagger改进
.NET7 Preview4 之OpenAPI swagger改进
26 0
|
3月前
在使用阿里云OpenAPI的翻译服务时
在使用阿里云OpenAPI的翻译服务时【1月更文挑战第15天】【1月更文挑战第74篇】
17 2
|
5月前
|
算法 API
阿里云OpenAPI 这个问题怎么解决?
阿里云OpenAPI 这个问题怎么解决?
37 1
|
7月前
|
存储 API 开发工具
将阿里云OpenAPI与App Inventor连接
将阿里云OpenAPI与App Inventor连接
337 1
|
8月前
|
关系型数据库 API 开发工具
RDS OpenAPI SDK的作用
RDS OpenAPI SDK的作用
123 2
|
8月前
|
安全 API 开发工具
阿里云OpenAPI中
阿里云OpenAPI中
97 1
|
Prometheus Cloud Native API
|
数据采集 算法 Dubbo
终于懂了,RPC和OpenApi的区别
终于懂了,RPC和OpenApi的区别
353 0
终于懂了,RPC和OpenApi的区别

热门文章

最新文章