基准测试报告

硬件环境

后端Mock服务所在服务器:

  • CPU: 4核8线程 Intel Cascade Lake @ 3.0GHz
  • RAM: 16G

网关节点所在服务器:

  • CPU: 4核8线程 Intel Cascade Lake @ 3.0GHz
  • RAM: 16G

测试工具占用资源很少,安装在网关节点服务器。

ShenYu 版本

  • ShenYu Admin: 2.6.0
  • ShenYu Bootstrap: 2.6.0

测试工具

wrk-4.2.0

测试用例说明

说明

  • 使用 Mock 服务模拟一个平均响应时长 20ms ,响应报文约 2k 的接口
  • 每次测试时长 3 分钟
  • JDK版本: OpenJdk-1.8.0
  • HTTP 请求端分别使用 NettyClientWebClient 进行测试
  • 日志级别为WARN
  • Apache ShenYu Bootstrap部署模式:单机部署
  • Apache ShenYu Admin部署在mock服务器上。

JVM 配置

  1. -Xmx 4g
  2. -Xms 4g
  3. -Xmn 1g
  4. -Xss 512k
  5. -XX: +DisableExplicitGC
  6. -XX: LargePageSizeInBytes=128m

公共配置

  • application.yml
  1. matchCache:
  2. selector:
  3. selectorEnabled: true
  4. initialCapacity: 10000 # initial capacity in cache
  5. maximumSize: 10000 # max size in cache
  6. rule:
  7. initialCapacity: 10000 # initial capacity in cache
  8. maximumSize: 65536 # max size in cache
  9. trie:
  10. enabled: true
  11. childrenSize: 10000
  12. pathVariableSize: 1000
  13. pathRuleCacheSize: 1000
  14. matchMode: antPathMatch
  1. netty:
  2. http:
  3. # set to false, user can custom the netty tcp server config.
  4. webServerFactoryEnabled: true
  5. selectCount: 1
  6. workerCount: 8
  7. accessLog: false
  8. serverSocketChannel:
  9. soRcvBuf: 87380
  10. soBackLog: 128
  11. soReuseAddr: false
  12. connectTimeoutMillis: 10000
  13. writeBufferHighWaterMark: 65536
  14. writeBufferLowWaterMark: 32768
  15. writeSpinCount: 16
  16. autoRead: false
  17. allocType: "pooled"
  18. messageSizeEstimator: 8
  19. singleEventExecutorPerGroup: true
  20. socketChannel:
  21. soKeepAlive: false
  22. soReuseAddr: false
  23. soLinger: -1
  24. tcpNoDelay: true
  25. soRcvBuf: 87380
  26. soSndBuf: 16384
  27. ipTos: 0
  28. allowHalfClosure: false
  29. connectTimeoutMillis: 10000
  30. writeBufferHighWaterMark: 65536
  31. writeBufferLowWaterMark: 32768
  32. writeSpinCount: 16
  33. autoRead: false
  34. allocType: "pooled"
  35. messageSizeEstimator: 8
  36. singleEventExecutorPerGroup: true
  1. file:
  2. enabled: false
  3. maxSize : 10
  1. cross:
  2. enabled: false
  1. logging:
  2. level:
  3. root: warn
  4. org.springframework.boot: warn
  5. org.apache.ibatis: warn
  6. org.apache.shenyu.bonuspoint: warn
  7. org.apache.shenyu.lottery: warn
  8. org.apache.shenyu: warn
  • logback.xml
  1. <root level="WARN">
  2. <appender-ref ref="ASYNC_STDOUT"/>
  3. <appender-ref ref="ASYNC_FILE"/>
  4. <appender-ref ref="ASYNC_ERROR_FILE"/>
  5. </root>

WebClient配置

  1. httpclient:
  2. strategy: webClient # netty
  3. connectTimeout: 45000 # 45000
  4. responseTimeout: 3000 # 3000
  5. readerIdleTime: 3000 # 3000
  6. writerIdleTime: 3000 # 3000
  7. allIdleTime: 3000 # 3000
  8. readTimeout: 3000 # 3000
  9. writeTimeout: 3000 # 3000
  10. wiretap: false # false
  11. keepAlive: false # false
  12. maxInMemorySize: 1 # 1
  13. pool:
  14. type: ELASTIC # ELASTIC
  15. name: proxy # proxy
  16. maxConnections: 16 # 16
  17. acquireTimeout: 45000 # 45000
  18. maxIdleTime: 3000 # 3000

NettyClient配置

  1. httpclient:
  2. strategy: netty # netty
  3. connectTimeout: 45000 # 45000
  4. responseTimeout: 3000 # 3000
  5. readerIdleTime: 3000 # 3000
  6. writerIdleTime: 3000 # 3000
  7. allIdleTime: 3000 # 3000
  8. readTimeout: 3000 # 3000
  9. writeTimeout: 3000 # 3000
  10. wiretap: false # false
  11. keepAlive: false # false
  12. maxInMemorySize: 1 # 1
  13. pool:
  14. type: ELASTIC # ELASTIC
  15. name: proxy # proxy
  16. maxConnections: 16 # 16
  17. acquireTimeout: 45000 # 45000
  18. maxIdleTime: 3000 # 3000

基准测试结果

  • 直接访问后端
QPS50% latency (ms)75% latency (ms)90% latency (ms)99% latency (ms)平均响应时间(ms)最大响应时间(ms)
28998.2019.8123.7828.2641.2420.92402.90
  • netty
currencyQPS50% latency (ms)75% latency (ms)90% latency (ms)99% latency (ms)平均响应时间(ms)最大响应时间(ms)
600 并发20472.9519.3725.3632.8969.9222.091043.33
800 并发20703.5523.5731.3240.1177.2826.11576.47
1000 并发20979.9129.2137.8647.2380.9131.20860.55
1200 并发21129.8832.4542.4052.6896.1035.061070
  • webClient
currencyQPS50% latency (ms)75% latency (ms)90% latency (ms)99% latency (ms)平均响应时间(ms)最大响应时间(ms)
600 并发18640.4715.7724.7738.2680.3120.32852.06
800 并发18723.4418.1228.6944.9695.323.52765.26
1000 并发18928.9919.9931.4249.09108.8425.931040
1200 并发18965.3722.1034.6254.48122.3128.661075

直接访问后端测试结果

测试结果

QPS50% latency (ms)75% latency (ms)90% latency (ms)99% latency (ms)平均响应时间(ms)最大响应时间(ms)
28998.2019.8123.7828.2641.2420.92402.90

测试截图

基准测试报告 - 图1

netty 测试结果

测试结果

currencyQPS50% latency (ms)75% latency (ms)90% latency (ms)99% latency (ms)平均响应时间(ms)最大响应时间(ms)
600 并发20472.9519.3725.3632.8969.9222.091043.33
800 并发20703.5523.5731.3240.1177.2826.11576.47
1000 并发20979.9129.2137.8647.2380.9131.20860.55
1200 并发21129.8832.4542.4052.6896.1035.061070

测试截图

600 并发

基准测试报告 - 图2基准测试报告 - 图3基准测试报告 - 图4

800 并发

基准测试报告 - 图5基准测试报告 - 图6基准测试报告 - 图7

1000 并发

基准测试报告 - 图8基准测试报告 - 图9基准测试报告 - 图10

1200 并发

基准测试报告 - 图11基准测试报告 - 图12基准测试报告 - 图13

webClient 测试结果

测试结果

currencyQPS50% latency (ms)75% latency (ms)90% latency (ms)99% latency (ms)平均响应时间(ms)最大响应时间(ms)
600 并发18640.4715.7724.7738.2680.3120.32852.06
800 并发18723.4418.1228.6944.9695.323.52765.26
1000 并发18928.9919.9931.4249.09108.8425.931040
1200 并发18965.3722.1034.6254.48122.3128.661075

测试截图

600 并发

基准测试报告 - 图14基准测试报告 - 图15基准测试报告 - 图16

800 并发

基准测试报告 - 图17基准测试报告 - 图18

1000 并发

基准测试报告 - 图19基准测试报告 - 图20

1200 并发

基准测试报告 - 图21基准测试报告 - 图22