Skip to main content

Apache ShenYu基准测试

moremind...About 3 minApache ShenYuApache ShenYubenchmark-test

什么是Apache ShenYu

Apache ShenYu是一个异步的,高性能的,跨语言的,响应式的Java API 网关。

Apache ShenYu 基准测试的环境

Mock服务器配置

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

Apache ShenYu Bootstrap配置

  • 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

测试工具下载

测试工具安装

yum -y install git  make gcc

git clone https://github.com/wg/wrk.git wrk

cd wrk

make

cp wrk /usr/local/bin/

测试工具安装位置

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

测试用例说明

说明

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

JVM配置

-Xmx 4g 
-Xms 4g 
-Xmn 1g 
-Xss 512k 
-XX: +DisableExplicitGC 
-XX: LargePageSizeInBytes=128m

公共配置

matchCache:
  selector:
    selectorEnabled: false
    initialCapacity: 10000 # initial capacity in cache
    maximumSize: 10000 # max size in cache
  rule:
    initialCapacity: 10000 # initial capacity in cache
    maximumSize: 65536 # max size in cache
trie:
  enabled: true
  childrenSize: 10000
  pathVariableSize: 1000
  pathRuleCacheSize: 1000
  matchMode: antPathMatch
netty:
  http:
  # set to false, user can custom the netty tcp server config.
  webServerFactoryEnabled: true
  selectCount: 1
  workerCount: 8
  accessLog: false
  serverSocketChannel:
    soRcvBuf: 87380
    soBackLog: 128
    soReuseAddr: false
    connectTimeoutMillis: 10000
    writeBufferHighWaterMark: 65536
    writeBufferLowWaterMark: 32768
    writeSpinCount: 16
    autoRead: false
    allocType: "pooled"
    messageSizeEstimator: 8
    singleEventExecutorPerGroup: true
  socketChannel:
    soKeepAlive: false
    soReuseAddr: false
    soLinger: -1
    tcpNoDelay: true
    soRcvBuf: 87380
    soSndBuf: 16384
    ipTos: 0
    allowHalfClosure: false
    connectTimeoutMillis: 10000
    writeBufferHighWaterMark: 65536
    writeBufferLowWaterMark: 32768
    writeSpinCount: 16
    autoRead: false
    allocType: "pooled"
    messageSizeEstimator: 8
    singleEventExecutorPerGroup: true

WebClient配置

httpclient:
  strategy: webClient # netty
  connectTimeout: 45000 # 45000
  responseTimeout: 3000 # 3000
  readerIdleTime: 3000 # 3000
  writerIdleTime: 3000 # 3000
  allIdleTime: 3000 # 3000
  readTimeout: 3000 # 3000
  writeTimeout: 3000 # 3000
  wiretap: false # false
  keepAlive: false # false
  maxInMemorySize: 1 # 1
  pool:
    type: ELASTIC # ELASTIC
    name: proxy # proxy
    maxConnections: 16 # 16
    acquireTimeout: 45000 # 45000
    maxIdleTime: 3000 # 3000

NettyClient配置

httpclient:
  strategy: netty # netty
  connectTimeout: 45000 # 45000
  responseTimeout: 3000 # 3000
  readerIdleTime: 3000 # 3000
  writerIdleTime: 3000 # 3000
  allIdleTime: 3000 # 3000
  readTimeout: 3000 # 3000
  writeTimeout: 3000 # 3000
  wiretap: false # false
  keepAlive: false # false
  maxInMemorySize: 1 # 1
  pool:
    type: ELASTIC # ELASTIC
    name: proxy # proxy
    maxConnections: 16 # 16
    acquireTimeout: 45000 # 45000
    maxIdleTime: 3000 # 3000

启动ShenYu和Mock服务

启动ShenYu Admin

tar -zxvf apache-shenyu-admin-2.6.0.tar.gz
cd apache-shenyu-admin-2.6.0
cd bin
./start.sh

启动ShenYu Bootstrap

tar -zxvf apache-shenyu-bootstrap-2.6.0.tar.gz
cd apache-shenyu-bootstrap-2.6.0
cd bin
./start.sh

启动Mock服务

nohup java -jar shenyu-examples-http.jar -server -Xmx4g -Xms4g -Xmn1g -Xss256k &

如何测试

测试mock服务

./wrk -t8 -c600 -T10s -d180s --latency http://ip:8189/test/requstBody

测试ShenYu Bootstrap

./wrk -t8 -c600 -T10s -d180s --latency http://localhost:9195/http/test/requestBody
./wrk -t8 -c800 -T10s -d180s --latency http://localhost:9195/http/test/requestBody
./wrk -t8 -c1000 -T10s -d180s --latency http://localhost:9195/http/test/requestBody
./wrk -t8 -c1200 -T10s -d180s --latency http://localhost:9195/http/test/requestBody

测试结果

直接访问后端

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
评论
  • 按正序
  • 按倒序
  • 按热度
Powered by Waline v2.15.8