我需要一些帮助来分析来自 Apache Bench 的日志:
Benchmarking texteli.com (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 requests
Server Software:
Server Hostname: texteli.com
Server Port: 80
Document Path: /4f84b59c557eb79321000dfa
Document Length: 13400 bytes
Concurrency Level: 200
Time taken for tests: 37.030 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 13524000 bytes
HTML transferred: 13400000 bytes
Requests per second: 27.01 [#/sec] (mean)
Time per request: 7406.024 [ms] (mean)
Time per request: 37.030 [ms] (mean, across all concurrent requests)
Transfer rate: 356.66 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 27 37 19.5 34 319
Processing: 80 6273 1673.7 6907 8987
Waiting: 47 3436 2085.2 3345 8856
Total: 115 6310 1675.8 6940 9022
Percentage of the requests served within a certain time (ms)
50% 6940
66% 6968
75% 6988
80% 7007
90% 7025
95% 7078
98% 8410
99% 8876
100% 9022 (longest request)
这个结果能告诉我什么?27 rps 是不是太慢了?
答案1
运行负载测试时,随意选择一个数字并命中服务器通常不是一个好方法。您已证明的是,只要访问者不介意等待约 7 秒才能加载请求,您的服务器就可以处理 200 个并发访问者。您可能想要做的是:
- 首先,建立一个基线。使用 1 个访问者(并发率为 1)。
- 第二,开始增加数字。例如,1、10、25、50、100、125、150、200 等。
- 最后,确保这些请求运行较长时间(即,不要只是启动它然后 ^C 它)
获得结果后,绘制图表:访客数量与平均请求时间,包括最大和最小条。基本上,任意应用程序的负载测试只有相关测试才有用;在这种情况下,例如,如果 1 位访客需要 6 秒才能加载一个页面,那么 200 位访客需要 7 秒才能加载一个页面,这听起来还不错,不是吗?
答案2
您可以通过设置启动请求数和并发请求数来开始,然后检查结果如下:
- Total Number of Requests per seconds
- Average Time Per Request
- Average waiting / processing / connecting times
然后你可以通过增加并发连接数来扩大规模,直到接近预期的用户数,观察服务的响应,重复多次,检查时间变化并取平均值