使用ab做性能測試
- 2019 年 11 月 22 日
- 筆記
安裝ab
apt install -y apache2-utils
開始測試
ab -t 5 -c 1000 "http://127.0.0.1:8000/dynamic_hello?hello=yzh"
- -t 持續的時間
- -c 並發量
等待一會,出結果
結果分析
This is ApacheBench, Version 2.3 <$Revision: 1807734 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking 127.0.0.1 (be patient) Finished 1740 requests Server Software: Server Hostname: 127.0.0.1 Server Port: 8000 Document Path: /dynamic_hello?hello=yzh Document Length: 17 bytes Concurrency Level: 1000 Time taken for tests: 5.261 seconds Complete requests: 1740 // 請求數 Failed requests: 0 // 失敗數 Total transferred: 196880 bytes HTML transferred: 31280 bytes Requests per second: 330.76 [#/sec] (mean) // QPS Time per request: 3023.304 [ms] (mean) // 用戶感受的平均響應時間 Time per request: 3.023 [ms] (mean, across all concurrent requests) // 服務端每個請求的處理時間 Transfer rate: 36.55 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 279 452.8 2 1034 Processing: 302 802 402.0 866 4229 Waiting: 280 695 372.7 731 4081 Total: 304 1082 732.1 869 5245 Percentage of the requests served within a certain time (ms) 50% 869 66% 909 75% 1583 80% 1939 90% 2009 95% 2638 98% 2647 99% 2649 100% 5245 (longest request)
關注這幾個指標就行了