安装ab工具
1 2 3 4 5 |
#查看命令所在包 [root@web02 /server]# yum provides ab #安装ab [root@web02 /server]# yum install -y httpd-tools |
工具使用
1 2 3 4 5 6 7 8 |
[root@web01 ~]# ab -n 200 -c 2 http://linux.try.com/ -n 请求次数 -c 请求的并发数 -k 保持长连接 #语法 Usage: ab [options] [http[s]://]hostname[:port]/path |
配置网站
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
[root@web01 ~]# vim /etc/nginx/conf.d/t_file.conf server { listen 80; server_name linux.try.com; location / { root /code/try; #index index.html index.htm; try_files $uri $uri/ @java; } location @java { proxy_pass http://172.16.1.8:8080; } } #配置 hosts [root@web01 ~]# vim /etc/hosts 10.0.0.7 linux.try.com |
ab测试nginx请求静态页
1 2 3 4 5 6 7 8 9 10 11 12 |
[root@web01 ~]# ab -n 20000 -c 20 http://linux.try.com/ Concurrency Level: 20 Time taken for tests: 1.639 seconds Complete requests: 20000 Failed requests: 0 Write errors: 0 Total transferred: 5120000 bytes HTML transferred: 220000 bytes Requests per second: 12200.40 [#/sec] (mean) Time per request: 1.639 [ms] (mean) Time per request: 0.082 [ms] (mean, across all concurrent requests) Transfer rate: 3050.10 [Kbytes/sec] received |
ab测试tomcat请求静态页
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
[root@web01 ~]# rm -rf /code/try Server Software: nginx/1.18.0 Server Hostname: linux.try.com Server Port: 80 Document Path: / Document Length: 7 bytes Concurrency Level: 20 Time taken for tests: 11.736 seconds Complete requests: 20000 Failed requests: 0 Write errors: 0 Total transferred: 5120000 bytes HTML transferred: 140000 bytes Requests per second: 1704.10 [#/sec] (mean) Time per request: 11.736 [ms] (mean) Time per request: 0.587 [ms] (mean, across all concurrent requests) Transfer rate: 426.03 [Kbytes/sec] received |