做简历的网站有,企业年金查询在哪查,wordpress短代码显示,用h5做简易网站代码该测试只是简单在同一台机器设备对spring cloud gateway网关和kong网关进行对比#xff0c;受限于笔者所拥有的资源#xff0c;此处仅做简单评测。
一、使用spring boot 的auth-service作为服务提供者
该服务提供了一个/health接口#xff0c;接口返回OK…
该测试只是简单在同一台机器设备对spring cloud gateway网关和kong网关进行对比受限于笔者所拥有的资源此处仅做简单评测。
一、使用spring boot 的auth-service作为服务提供者
该服务提供了一个/health接口接口返回OK运行的地址为192.168.188.108:8174
二、使用kong 网关代理该服务
2.1、创建service
curl -i -s -X POST http://localhost:8001/services --data nameauth-service --data urlhttp://192.168.188.108:81742.2. 给服务绑定route
curl -i -X POST http://localhost:8001/services/auth-service/routes --data paths[]/auth-service --data nameauth-service_route2.3、测试通过kong网关来进行访问
[rootlocalhost ~]# curl -X GET http://192.168.188.101:8000/auth-service/health
ok2.4、使用upstream来进行负载均衡
创建upstream
curl -X POST http://localhost:8001/upstreams --data nameauth_upstream给upstream绑定目标服务
curl -X POST http://localhost:8001/upstreams/auth_upstream/targets --data target192.168.188.108:8174
curl -X POST http://localhost:8001/upstreams/auth_upstream/targets --data target192.168.188.108:8176更新service指定的url地址
curl -X PATCH http://localhost:8001/services/auth-service --data hostauth_upstream三、搭建spring cloud 的gateway网关环境
?xml version1.0 encodingUTF-8?
!--suppress MavenPropertyInParent --
project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdparentartifactIdapi-module-gateways/artifactIdgroupIdcom.api/groupIdversion${env.project.version}/version/parentmodelVersion4.0.0/modelVersionartifactIdmanager-gateway/artifactIdpackagingjar/packagingdescription后台管理网关/descriptionpropertiesmaven.compiler.source8/maven.compiler.sourcemaven.compiler.target8/maven.compiler.target/properties!-- 具体的jar包依赖 --dependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter/artifactIdexclusionsexclusiongroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-logging/artifactId/exclusion/exclusions/dependencydependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-gateway/artifactId/dependency!-- 注册中心与配置中心 --dependencygroupIdcom.alibaba.cloud/groupIdartifactIdspring-cloud-starter-alibaba-nacos-discovery/artifactId/dependencydependencygroupIdcom.alibaba.cloud/groupIdartifactIdspring-cloud-starter-alibaba-nacos-config/artifactId/dependencydependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-openfeign-core/artifactId/dependencydependencygroupIdio.github.openfeign/groupIdartifactIdfeign-okhttp/artifactId/dependencydependencygroupIdorg.projectlombok/groupIdartifactIdlombok/artifactIdscopeprovided/scope/dependency/dependenciesbuildpluginsplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactIdversion2.1.0.RELEASE/versionexecutionsexecutiongoalsgoalrepackage/goal/goals/execution/executions/plugin/plugins/build/project
bootstrap.yaml
server:port: 8171
spring:cloud:gateway:discovery:locator:enabled: true routes:- id: auth-serviceuri: lb://auth-servicepredicates:- Path/auth-service/**filters:- RewritePath/auth-service/(?path.*), /$\{path}
feign:client:config:default:connectTimeout: 10000readTimeout: 10000
open:gateway:excludes: skipUrl:- /config/all/content- /auth/manager/captcha- /auth/manager/login- /auth/manager/isAlreadylogin- /config/dick/selectAllDick- /config/menu/selectTreeDick- /health测试接口能否正常使用
curl -X GET http://192.168.188.108:8171/auth-service/health四、性能测试对比
4.1、1000个请求、100并发场景 kong 网关 [rootlocalhost wrk-4.2.0]# ab -n 1000 -c 100 http://192.168.188.101:8000/auth-service/health
This is ApacheBench, Version 2.3 $Revision: 1430300 $
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking 192.168.188.101 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requestsServer Software: kong/3.9.0.0-enterprise-edition
Server Hostname: 192.168.188.101
Server Port: 8000Document Path: /auth-service/health
Document Length: 2 bytesConcurrency Level: 100
Time taken for tests: 0.321 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 325331 bytes
HTML transferred: 2000 bytes
Requests per second: 3112.66 [#/sec] (mean)
Time per request: 32.127 [ms] (mean)
Time per request: 0.321 [ms] (mean, across all concurrent requests)
Transfer rate: 988.91 [Kbytes/sec] receivedConnection Times (ms)min mean[/-sd] median max
Connect: 1 8 3.9 8 17
Processing: 3 21 9.9 18 67
Waiting: 3 19 9.3 15 62
Total: 10 29 10.8 28 79Percentage of the requests served within a certain time (ms)50% 2866% 3075% 3380% 3690% 4495% 4898% 6299% 70100% 79 (longest request)spring cloud gateway
[rootlocalhost wrk-4.2.0]# ab -n 1000 -c 100 http://192.168.188.108:8171/auth-service/health
This is ApacheBench, Version 2.3 $Revision: 1430300 $
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking 192.168.188.108 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requestsServer Software:
Server Hostname: 192.168.188.108
Server Port: 8171Document Path: /auth-service/health
Document Length: 2 bytesConcurrency Level: 100
Time taken for tests: 0.676 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 182000 bytes
HTML transferred: 2000 bytes
Requests per second: 1478.79 [#/sec] (mean)
Time per request: 67.623 [ms] (mean)
Time per request: 0.676 [ms] (mean, across all concurrent requests)
Transfer rate: 262.83 [Kbytes/sec] receivedConnection Times (ms)min mean[/-sd] median max
Connect: 0 9 7.2 7 32
Processing: 13 55 19.6 50 108
Waiting: 12 53 18.5 50 104
Total: 24 63 18.4 57 113Percentage of the requests served within a certain time (ms)50% 5766% 6975% 7880% 8290% 9095% 9898% 10599% 111100% 113 (longest request)4.2、10000个请求、100并发场景 kong网关 [rootlocalhost wrk-4.2.0]# ab -n 10000 -c 100 http://192.168.188.101:8000/auth-service/health
This is ApacheBench, Version 2.3 $Revision: 1430300 $
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking 192.168.188.101 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requestsServer Software: kong/3.9.0.0-enterprise-edition
Server Hostname: 192.168.188.101
Server Port: 8000Document Path: /auth-service/health
Document Length: 2 bytesConcurrency Level: 100
Time taken for tests: 1.549 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 3250520 bytes
HTML transferred: 20000 bytes
Requests per second: 6455.87 [#/sec] (mean)
Time per request: 15.490 [ms] (mean)
Time per request: 0.155 [ms] (mean, across all concurrent requests)
Transfer rate: 2049.31 [Kbytes/sec] receivedConnection Times (ms)min mean[/-sd] median max
Connect: 1 5 2.0 5 13
Processing: 2 10 4.4 10 44
Waiting: 2 10 4.0 9 42
Total: 4 15 5.0 14 49Percentage of the requests served within a certain time (ms)50% 1466% 1675% 1880% 1990% 2395% 2598% 2899% 31100% 49 (longest request)spring cloud gateway
[rootlocalhost wrk-4.2.0]# ab -n 10000 -c 100 http://192.168.188.108:8171/auth-service/health
This is ApacheBench, Version 2.3 $Revision: 1430300 $
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking 192.168.188.108 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requestsServer Software:
Server Hostname: 192.168.188.108
Server Port: 8171Document Path: /auth-service/health
Document Length: 2 bytesConcurrency Level: 100
Time taken for tests: 4.399 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 1820000 bytes
HTML transferred: 20000 bytes
Requests per second: 2273.37 [#/sec] (mean)
Time per request: 43.988 [ms] (mean)
Time per request: 0.440 [ms] (mean, across all concurrent requests)
Transfer rate: 404.06 [Kbytes/sec] receivedConnection Times (ms)min mean[/-sd] median max
Connect: 0 4 4.7 2 36
Processing: 6 40 9.5 39 89
Waiting: 6 39 9.7 38 89
Total: 13 44 8.7 42 91Percentage of the requests served within a certain time (ms)50% 4266% 4575% 4780% 4990% 5595% 5998% 6699% 72100% 91 (longest request)4.3、100000个请求、500并发场景 kong网关 [rootlocalhost wrk-4.2.0]# ab -n 100000 -c 500 http://192.168.188.101:8000/auth-service/health
This is ApacheBench, Version 2.3 $Revision: 1430300 $
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking 192.168.188.101 (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requestsServer Software: kong/3.9.0.0-enterprise-edition
Server Hostname: 192.168.188.101
Server Port: 8000Document Path: /auth-service/health
Document Length: 2 bytesConcurrency Level: 500
Time taken for tests: 14.316 seconds
Complete requests: 100000
Failed requests: 0
Write errors: 0
Total transferred: 32598168 bytes
HTML transferred: 200000 bytes
Requests per second: 6985.06 [#/sec] (mean)
Time per request: 71.581 [ms] (mean)
Time per request: 0.143 [ms] (mean, across all concurrent requests)
Transfer rate: 2223.64 [Kbytes/sec] receivedConnection Times (ms)min mean[/-sd] median max
Connect: 0 33 64.3 29 3032
Processing: 13 38 18.7 35 353
Waiting: 3 37 18.5 35 352
Total: 23 70 67.0 65 3067Percentage of the requests served within a certain time (ms)50% 6566% 6775% 6980% 7190% 7595% 8198% 9399% 120100% 3067 (longest request)spring cloud gateway
[rootlocalhost wrk-4.2.0]# ab -n 100000 -c 500 http://192.168.188.108:8171/auth-service/health
This is ApacheBench, Version 2.3 $Revision: 1430300 $
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking 192.168.188.108 (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requestsServer Software:
Server Hostname: 192.168.188.108
Server Port: 8171Document Path: /auth-service/health
Document Length: 2 bytesConcurrency Level: 500
Time taken for tests: 41.851 seconds
Complete requests: 100000
Failed requests: 0
Write errors: 0
Total transferred: 18200000 bytes
HTML transferred: 200000 bytes
Requests per second: 2389.42 [#/sec] (mean)
Time per request: 209.256 [ms] (mean)
Time per request: 0.419 [ms] (mean, across all concurrent requests)
Transfer rate: 424.68 [Kbytes/sec] receivedConnection Times (ms)min mean[/-sd] median max
Connect: 0 130 711.8 2 15067
Processing: 7 73 13.3 71 285
Waiting: 6 73 13.0 70 234
Total: 19 203 712.8 74 15156Percentage of the requests served within a certain time (ms)50% 7466% 7775% 8180% 8490% 10495% 107898% 307299% 3093100% 15156 (longest request)kong网关与Spring cloud网关的性能对比测试场景指标Kong 网关Spring Cloud Gateway十万 请求, 10并发请求完成时间 (秒)37.81553.754每秒请求数 (#/sec)2644.481860.34平均每个请求时间 (ms)3.7815.375传输速率 (Kbytes/sec)839.31330.6550% 响应时间 (ms)3595% 响应时间 (ms)87最大响应时间 (ms)2083十万 请求, 50并发请求完成时间 (秒)17.01839.327每秒请求数 (#/sec)5876.282542.79平均每个请求时间 (ms)8.50919.663传输速率 (Kbytes/sec)1865.07451.9450% 响应时间 (ms)81995% 响应时间 (ms)1326最大响应时间 (ms)59162十万 请求, 100 并发请求完成时间 (秒)15.57339.906每秒请求数 (#/sec)6421.282505.89平均每个请求时间 (ms)15.57339.906传输速率 (Kbytes/sec)2031.99445.3850% 响应时间 (ms)153895% 响应时间 (ms)2555最大响应时间 (ms)76183十万 请求, 200 并发请求完成时间 (秒)14.86141.003每秒请求数 (#/sec)6729.092438.82平均每个请求时间 (ms)29.72282.007传输速率 (Kbytes/sec)2049.31433.4650% 响应时间 (ms)297995% 响应时间 (ms)4298最大响应时间 (ms)120212十万 请求, 500 并发请求完成时间 (秒)15.05443.48每秒请求数 (#/sec)6642.812299.91平均每个请求时间 (ms)75.269217.4传输速率 (Kbytes/sec)2108.14408.7750% 响应时间 (ms)688195% 响应时间 (ms)961091最大响应时间 (ms)111115144Kong 网关在高并发情况下整体性能优于 Spring Cloud Gateway主要体现在更快的响应时间、更高的每秒请求数以及较低的延迟波动。