首页 > 代码库 > apache ab工具压力测试

apache ab工具压力测试

apache本身自带了一个测试工具ab,在apache的安装目录bin目录下

ab的使用方法:

Usage: ab [options] [http[s]://]hostname[:port]/path

-n 测试会话中所执行的请求个数,默认时,仅执行一个请求
-c 一次产生的请求个数。默认是一次一个
-t 测试所进行的最大秒数
-v 设置显示信息的详细程度 - 4或更大值会显示头信息, 3或更大值可以显示响应代码(404, 200等), 2或更大值可以显示警告和其他信息。 -V 显示版本号zui

最常用的参数是 -n 和 -c 例如:

root@:localhost:/usr/local/apache/bin> ./ab -n1000 -c10 http://localhost/index.php
This is ApacheBench, Version 2.3 <$Revision: 1528965 $>Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking 192.168.90.222 (be patient)Completed 100 requestsCompleted 200 requestsCompleted 300 requestsCompleted 400 requestsCompleted 500 requestsCompleted 600 requestsCompleted 700 requestsCompleted 800 requestsCompleted 900 requestsCompleted 1000 requestsFinished 1000 requestsServer Software: Boa/0.94.13Server Hostname: 192.168.90.222Server Port: 80Document Path: /Document Length: 41 bytesConcurrency Level: 10Time taken for tests: 0.173 secondsComplete requests: 1000Failed requests: 0Total transferred: 228000 bytesHTML transferred: 41000 bytesRequests per second: 5780.51 [#/sec] (mean)Time per request: 1.730 [ms] (mean)Time per request: 0.173 [ms] (mean, across all concurrent requests)Transfer rate: 1287.07 [Kbytes/sec] receivedConnection Times (ms) min mean[+/-sd] median maxConnect: 0 0 0.2 0 1Processing: 0 1 7.8 1 80Waiting: 0 1 7.3 0 76Total: 0 2 7.7 1 80Percentage of the requests served within a certain time (ms) 50% 1 66% 1 75% 1 80% 1 90% 1 95% 1 98% 2 99% 76 100% 80 (longest request)