项目即将上线 老大说 小聂 咱的项目需要压测下 测试的工具有很多 小聂选择了最为简单ab 测试
很多同学可能对ab 测试不了解 请点击 apache性能测试工具ab使用详解 详细了解
由于是post api接口 我写了以下的sh脚本
#!/usr/bin/env bash echo "开始测试" ab -n4000 -c20 -p "login.json" -T "application/json" "http://localhost:8082/plugin/login" echo "测试结束"
login.json是 要post 过去的参数
{ "namespace":"liuyanban", "certificate":"5791b91bd63c82760c9f93ef", "logintype":0, "frame":"af", "openId": "c_1" }
测试结果如下
./login.sh 开始测试 This is ApacheBench, Version 2.3 <$Revision: 1706008 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking localhost (be patient) Completed 400 requests Completed 800 requests Completed 1200 requests Completed 1600 requests Completed 2000 requests Completed 2400 requests Completed 2800 requests Completed 3200 requests Completed 3600 requests Completed 4000 requests Finished 4000 requests Server Software: Server Hostname: localhost Server Port: 8082 Document Path: /plugin/login Document Length: 48 bytes Concurrency Level: 20 Time taken for tests: 4.653 seconds Complete requests: 4000 Failed requests: 0 Total transferred: 1440000 bytes Total body sent: 1160000 HTML transferred: 192000 bytes Requests per second: 859.68 [#/sec] (mean) Time per request: 23.264 [ms] (mean) Time per request: 1.163 [ms] (mean, across all concurrent requests) Transfer rate: 302.23 [Kbytes/sec] received 243.47 kb/s sent 545.70 kb/s total Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.1 0 5 Processing: 2 23 5.5 20 49 Waiting: 2 23 5.5 20 49 Total: 4 23 5.5 21 49 Percentage of the requests served within a certain time (ms) 50% 21 66% 24 75% 27 80% 28 90% 31 95% 34 98% 38 99% 42 100% 49 (longest request) 测试结束
很简单的完成了我的测试需求
你打算打赏多少钱呢?
(微信扫一扫)