rest - 加特林测试中的高响应时间
问题描述
我对 Gatling 和 API 响应时间有疑问。我想用一定数量的用户(示例中的 200 个)测试端点的性能(响应时间)。
我在https://my-remote-machine/rest/v1/auth-token中有一个端点,用于获取有效的令牌,使用凭据执行 POST 操作。
结果
阿帕奇基准
运行下一个命令:
ab -T 'application/json' -n 200 -c 200 -p creds https://my-remote-machine/rest/v1/auth-token
我得到下一个响应时间:
Connection Times (ms)
min mean[+/-sd] median max
Connect: 101 112 75.4 104 1139
Processing: 66 85 79.6 73 1036
Waiting: 66 85 79.6 73 1035
Total: 169 197 111.8 177 1209
Percentage of the requests served within a certain time (ms)
50% 177
66% 180
75% 185
80% 188
90% 196
95% 236
98% 418
99% 1155
100% 1209 (longest request)
在169 毫秒和1209 毫秒之间
但是当我使用 Gatling 时,响应时间非常长,我不知道为什么会这样。(测试在本地和同一 vShpere 主机中的 Jenkins 管道中执行,网络延迟更少,结果相同)
加特林代码
val httpProtocol = http.baseUrl("https://my-remote-machine/rest/v1/")
val scn = scenario(scenarioName)
.exec(
http("my-auth-requests")
.post("auth-token")
.body(StringBody("{ \"username\":\"admin\", \"password\":\"mypassword\" }"))
.header("Content-Type", "application/json")
.check(status.is(200))
setUp(scn.inject(atOnceUsers(numberOfUsers))).protocols(httpProtocol)
结果:
================================================================================
---- Global Information --------------------------------------------------------
> request count 200 (OK=200 KO=0 )
> min response time 365 (OK=365 KO=- )
> max response time 3322 (OK=3322 KO=- )
> mean response time 2359 (OK=2359 KO=- )
> std deviation 750 (OK=750 KO=- )
> response time 50th percentile 2544 (OK=2544 KO=- )
> response time 75th percentile 2946 (OK=2946 KO=- )
> response time 95th percentile 3260 (OK=3260 KO=- )
> response time 99th percentile 3306 (OK=3306 KO=- )
> mean requests/sec 50 (OK=50 KO=- )
---- Response Time Distribution ------------------------------------------------
> t < 800 ms 12 ( 6%)
> 800 ms < t < 1200 ms 10 ( 5%)
> t > 1200 ms 178 ( 89%)
> failed 0 ( 0%)
================================================================================
在365 毫秒和3322 毫秒之间,这比 Apache Benchmark 高得多
我已经重复了很多次测试并且总是得到相同的结果。
有什么线索吗?
解决方案
推荐阅读
- angular - 日期格式 - 角度
- android - 以编程方式添加视图阻塞主线程
- javascript - 与 Chrome 相比,IE11 中计算 offsetWidth 的值不同
- php - Laravel 多个连接?
- mysql - 如何将值插入十进制(65,0)并使用 Golang 从数据库中检索它们?
- file - os.File、io.Reader 和 os.Stdin 的区别
- html - 如何使用 Angular 6 中的类名更改背景颜色?
- javascript - Wordpress 中的 jQuery 与控制台中的工作方式不同
- python - 如何使用 scipy gaussian_kde 获得概率密度函数?
- python - 张量值不正确