安裝ab命令 html
[root@master ~]# yum -y install httpd-tools
硬件配置型號
[root@master ~]# dmidecode | grep "Product Name" Product Name: VMware Virtual Platform Product Name: 440BX Desktop Reference Platform
CPU
[root@master ~]# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq Intel(R) Core(TM) i3-2348M CPU @ 2.30GHz
內存
[root@master ~]# dmidecode|grep -P -A5 "Memory\s+Device" | grep Size |grep -v Range | cat -n 1 Size: 512 MB
軟件環境
操做系統
[root@master ~]# cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core)
服務版本
[root@master ~]# /usr/local/nginx/sbin/nginx -v nginx version: liujunjun/1.0
測試軟件
[root@master ~]# ab -V 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/
併發測試
說明:測試基於Linux系統。nginx
1000併發
測試1000併發,處理10000請求:apache
[root@master ~]# ab -c 1000 -n 10000 http://192.168.1.222/static/index.html 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.1.222 (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 requests Server Software: liujunjun/1.0 (服務器軟件名稱及版本信息) Server Hostname: 192.168.1.222 (服務器主機名) Server Port: 80 (服務器端口) Document Path: /static/index.html (供測試的URL路徑) Document Length: 14 bytes (供測試的URL返回的文檔大小) Concurrency Level: 1000 (併發數) Time taken for tests: 1.476 seconds (壓力測試消耗的總時間) Complete requests: 10000 (壓力測試的的總次數) Failed requests: 0 (失敗的請求數) Write errors: 0 Total transferred: 2450000 bytes (傳輸的總數據量) HTML transferred: 140000 bytes (HTML文檔的總數據量) Requests per second: 6776.24 [#/sec] (mean) (平均每秒的請求數) Time per request: 147.574 [ms] (mean) (全部併發用戶(這裏是1000)都請求一次的平均時間) Time per request: 0.148 [ms] (mean, across all concurrent requests) (單個用戶請求一次的平均時間) Transfer rate: 1621.27 [Kbytes/sec] received (傳輸速率,單位:KB/s) Connection Times (ms) min mean[+/-sd] median max Connect: 1 76 253.6 4 1020 Processing: 2 20 28.9 13 418 Waiting: 1 16 28.2 10 418 Total: 8 96 266.0 16 1425 Percentage of the requests served within a certain time (ms) 這個表第一行表示有50%的請求都是在16ms內完成的,能夠看到這個值是比較接近平均系統響應時間,以此類推。 50% 16 66% 16 75% 17 80% 19 90% 106 95% 1030 98% 1037 99% 1218 100% 1425 (longest request)
2000併發
[root@master ~]# cat /proc/sys/fs/file-max 44685 [root@master ~]# ulimit -n 1024
臨時修改
[root@master ~]# ulimit -HSn 2048
永久修改
[root@master ~]# ulimit -a 65535
[root@master ~]# ab -c 2000 -n 40000 http://192.168.1.222/static/index.html 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.1.222 (be patient) Completed 4000 requests Completed 8000 requests Completed 12000 requests Completed 16000 requests Completed 20000 requests Completed 24000 requests Completed 28000 requests Completed 32000 requests Completed 36000 requests Completed 40000 requests Finished 40000 requests Server Software: liujunjun/1.0 Server Hostname: 192.168.1.222 Server Port: 80 Document Path: /static/index.html Document Length: 14 bytes Concurrency Level: 2000 Time taken for tests: 5.719 seconds Complete requests: 40000 Failed requests: 1 (Connect: 0, Receive: 0, Length: 1, Exceptions: 0) Write errors: 0 Non-2xx responses: 1 Total transferred: 9800112 bytes HTML transferred: 560180 bytes Requests per second: 6993.66 [#/sec] (mean) Time per request: 285.973 [ms] (mean) Time per request: 0.143 [ms] (mean, across all concurrent requests) Transfer rate: 1673.31 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 158 443.7 4 3021 Processing: 6 19 40.6 13 1832 Waiting: 1 16 40.4 10 1832 Total: 11 177 451.5 17 3427 Percentage of the requests served within a certain time (ms) 50% 17 66% 18 75% 20 80% 21 90% 1023 95% 1029 98% 1048 99% 3023 100% 3427 (longest request)
測試總結
數據彙總
請求鏈接數 | 併發數 | 請求失敗數 | 每秒處理請求數 | 一次併發數請求響應時間(ms) | 全體請求完成時間(s) | 請求成功率 |
10000 | 1000 | 0 | 6994 |
147.574 |
1.476 |
100% |
40000 | 2000 | 0 | 6994 | 285.973 |
5.719 |
100% |