ab命令压测
在性能調優中,ab命令和iperf命令比較好用的,下面就介紹一下ab命令
ApacheBench
ab是apacheBench的縮寫,是一個單線程命令,是Apache服務器自帶的一個web壓力測試工具,最初是用于測試Apache HTTP Server。使用時,ab命令會創建并發訪問線程,模擬多個訪問者同時對某一個URL地址進行訪問。
使用的方法:
ab [option] [http://]host[:port]/path
例如:ab -n 100 -c 10 "http://en.wikipedia.org/wiki/Main_Page"
其中[option]是ab命令提供的可選參數,列舉一些常用的參數:
-n ?//requests Number of requests to perform 指定壓力測試總共訪問頁面的次數,默認是1
-c?//concurrency Number of multiple requests to make at a time 用于一次產生請求的并發數,默認是1
-r //Don't exit on socket receive errors.指定接收到錯誤信息時不退出程序。
-B //address Address to bind to when making outgoing connections 綁定出口IP地址
-t?//timelimit Seconds to max. to spend on benchmarking?This implies -n 50000 測試所進行的最大秒數。其內部隱含值是-n 50000。它可以使對服務器的測試限制在一個固定的總時間以內。默認時,沒有時間限制。
-s //timeout ?Seconds to max. wait for each response?Default is 30 seconds ?每個相應的最長的時間,默認是30秒
-g //filename Output collected data to gnuplot format file ?輸出結果信息到gnuplot格式的文件中。
-e //filename ?Output CSV file with percentages served ? 輸出結果信息到CSV格式的文件中。
-S // Do not show confidence estimators and warnings.?不顯示預估和警告信息。
-d //Do not show percentiles served table.?不顯示百分比。
-k //Use HTTP KeepAlive feature ? ?使用HTTP的KeepAlive特性。
-b //windowsize ? Size of TCP send/receive buffer, in bytes TCP的發送/接受窗口,以字節為單位
-p?//postfile File containing data to POST 包含需要post的數據文件,例如:-p ?a.txt,此外還需要結合-T,并且文件的內容需類似像"key1=value1&key2=vaule2"形式
-T?//content-type Content-type header for POSTing 設置Context-Type請求頭信息,如-T “application/x-www-form-urlencoded”默認值為text/plain
-X //proxy:port ?Proxyserver and port number to use?指定使用的代理服務器和端口號,例如:"126.10.10.3:88"
-v?//verbosity How much troubleshooting info to print 設置打印幫助信息的詳細程度,4或更大值會顯示頭信息, 3或更大值可以顯示響應代碼(404, 200等), 2或更大值可以顯示警告和其他信息。
-w?//Print out results in HTML tables?以HTML表的格式輸出結果。默認時,它是白色背景的兩列寬度的一張表。
-i ?//Use HEAD instead of GET 使用HEAD請求代替GET請求
-C?//cookie-name=value?添加cookie信息,其典型形式是name=value的一個參數對。此參數可以重復,用逗號分割。
-H //attribute ? ?Add Arbitrary header line, eg. 'Accept-Encoding: gzip'?Inserted after all normal header lines. (repeatable)?添加任意的請求頭,例如:"Accept-Encoding: gzip",此參數可重復
-P?// proxy-auth-username:password ?對一個中轉代理提供BASIC認證信任。用戶名和密碼用英文冒號隔開,并以base64編碼形式發送。無論服務器是否需要(即, 是否發送了401認證需求代碼),此字符串都會被發送。
-A //Add Basic WWW Authentication, the attributes?are a colon separated username and password.基本網絡認證,用戶名和密碼之間用英文冒號隔開。
-x //attributes ? String to insert as table attributes?插入字符串作為table標簽的屬性。
-y //attributes ? String to insert as tr attributes?插入字符串作為tr標簽的屬性。
-z //attributes ? String to insert as td or th attributes?插入字符串作為td標簽的屬性。
總結
- 上一篇: 将PPT转换成PDF软件哪个最好用
- 下一篇: php excel转数组,php将exc