ab指令格式
ab指令放在apache目錄bin目錄下面,使用方法如下:
/ab -n 3000 -c 3000 http://www.local.com/(此為伺服器下測試的頁面位址)
其中-n代表每次并發量,-c代表總共發送的數量
2、測試結果分析
[root@Svr107 bin]# ./ab -n 3000 -c 3000 http://www.local.com/
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 www.twioo.com (be patient)
Completed 300 requests
Completed 600 requests
Completed 900 requests
Completed 1200 requests
Completed 1500 requests
Completed 1800 requests
Completed 2100 requests
Completed 2400 requests
Completed 2700 requests
Completed 3000 requests
Finished 3000 requests
Server Software: nginx/0.7.65
Server Hostname: www.test.com
Server Port: 80
Document Path: / ###請求的資源
Document Length: 50679 bytes ###文檔傳回的長度,不包括相應頭
Concurrency Level: 3000 ###并發個數
Time taken for tests: 30.449 seconds ###總請求時間
Complete requests: 3000 ###總請求數
Failed requests: 0 ###失敗的請求數
Write errors: 0
Total transferred: 152745000 bytes
HTML transferred: 152037000 bytes
Requests per second: 98.52 [#/sec] (mean) ###平均每秒的請求數
Time per request: 30449.217 [ms] (mean) ###平均每個請求消耗的時間
Time per request: 10.150 [ms] (mean, across all concurrent requests) ###上面的請求除以并發數
Transfer rate: 4898.81 [Kbytes/sec] received ###傳輸速率
Connection Times (ms)
min mean[+/-sd] median max
Connect: 2 54 27.1 55 98
Processing: 51 8452 5196.8 7748 30361
Waiting: 50 6539 5432.8 6451 30064
Total: 54 8506 5210.5 7778 30436
Percentage of the requests served within a certain time (ms)
50% 7778 ###50%的請求都在7778Ms内完成
66% 11059
75% 11888
80% 12207
90% 13806
95% 18520
98% 24232
99% 24559
100% 30436 (longest request)
3、如果用ab通路的是他本機上的web伺服器,使用127.0.0.1或者是web伺服器上的網卡IP位址,這個是不走網絡裝置的,可以忽略網絡消耗
4、ab使用的一些問題
a、ab指令在一般系統上面做測試時候,一般并發不能超過1024個,其實是因為因為系統限制每個程序打開的最大檔案數為1024,可以用ulimit -a來檢視
open files (-n) 65536 ##這個我系統已經修改過
b、-n 可以指定最大請求數,但是不能超過50000個
c、-v n 當n>=2 時,可以顯示發送的http請求頭,和響應的http頭及内容,壓力測試時不要這麼做
本文轉自 水滴的曆程 51CTO部落格,原文連結:http://blog.51cto.com/12390959/1932835