ab测试语法
ab -n 全部请求数 -c 并发数 测试url
例如:ab -n 10000 -c 1000 http://myweb.com/test.html
Server Software: Apache/2.0.55
Server Hostname: localhost
Server Port: 80
Document Path: /test.html
Document Length: 82522 bytes #请求文档大小
Concurrency Level: 50 #并发数
Time taken for tests: 92.76140 seconds #全部请求完成耗时
Complete requests: 10000 #全部请求数
Failed requests: 1974 #失败的请求
(Connect: 0, Length: 1974, Exceptions: 0)
Write errors: 0
Total transferred: 827019400 bytes #总传输大小
HTML transferred: 825219400 bytes
Requests per second: 108.61 [#/sec] (mean) #每秒请求数(平均)
Time per request: 460.381 [ms] (mean) #每次并发请求时间(所有并发)
Time per request: 9.208 [ms] (mean, across all concurrent requests) #每一请求时间(并发平均)
Transfer rate: 8771.39 [Kbytes/sec] received #传输速率 单位:KB/s
Connection Times (ms) #连接时间
min mean[+/-sd] median max
Connect(#连接): 0 0 2.1 0 46
Processing(#处理): 31 458 94.7 438 1078
Waiting(#等待): 15 437 87.5 422 938
Total: 31 458 94.7 438 1078
在上面的测试中,我们设置的压力测试总次数以及并发数并没有让服务器感觉到什么「压力」,
现在我们再来看一个「压力山大」的执行命令:
ab -n 100000 -c 1000 localhost/index.php
这个时候apache就直接罢工——拒绝访问了
##############################################
ab -n 100000 -c 1000 localhost/index.php
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
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) Test aborted after 10 failuresapr_socket_connect():
由于目标计算机积极拒绝,无法连接。 (730061)