ab 壓力測試

2021-06-13 15:01:00 字數 2486 閱讀 9206

apache自帶的ab的壓力測試:

以前安裝好apache總是不知道該如何測試apache的效能,現在總算找到乙個測試工具了。就是apache自帶的測試工具ab(apache benchmark).在apache的bin目錄下。

格式: ./ab [options] [http://]hostname[:port]/path

引數:-n requests number of requests to perform

//在測試會話中所執行的請求個數。預設時,僅執行乙個請求

-c concurrency number of multiple requests to make

//一次產生的請求個數。預設是一次乙個。

-t timelimit seconds to max. wait for responses

//測試所進行的最大秒數。其內部隱含值是-n 50000。它可以使對伺服器的測試限制在乙個固定的總時間以內。預設時,沒有時間限制。

-p postfile file containing data to post

//包含了需要post的資料的檔案.

-t content-type content-type header for posting

//post資料所使用的content-type頭資訊。

-v verbosity how much troubleshooting info to print

//設定顯示資訊的詳細程度 - 4或更大值會顯示頭資訊, 3或更大值可以顯示響應**(404, 200等), 2或更大值可以顯示警告和其他資訊。 -v 顯示版本號並退出。

-w print out results in html tables

//以html表的格式輸出結果。預設時,它是白色背景的兩列寬度的一張表。

-i use head instead of get

// 執行head請求,而不是get。

-x attributes string to insert as table attributes

//-y attributes string to insert as tr attributes

//-z attributes string to insert as td or th attributes

//-c attribute add cookie, eg. 'apache=1234. (repeatable)

//-c cookie-name=value 對請求附加乙個cookie:行。 其典型形式是name=value的乙個引數對。此引數可以重複。

-h attribute add arbitrary header line, eg. 'accept-encoding: gzip'

inserted after all normal header lines. (repeatable)

-a attribute add basic www authentication, the attributes

are a colon separated username and password.

-p attribute add basic proxy authentication, the attributes

are a colon separated username and password.

//-p proxy-auth-username:password 對乙個中轉**提供basic認證信任。使用者名稱和密碼由乙個:隔開,並以base64編碼形式傳送。無論伺服器是否需要(即, 是否傳送了401認證需求**),此字串都會被傳送。

//-attributes 設定 屬性的字串. 缺陷程式中有各種靜態宣告的固定長度的緩衝區。另外,對命令列引數、伺服器的響應頭和其他外部輸入的解析也很簡單,這可能會有不良後果。它沒有完整地實現 http/1.x; 僅接受某些'預想'的響應格式。 strstr(3)的頻繁使用可能會帶來效能問題,即, 你可能是在測試ab而不是伺服器的效能。

引數很多,一般我們用 -c 和 -n 引數就可以了

-n1000 總請求數

-c10  併發使用者數

ab壓力測試

1.我的環境是windows下的phpstudy,進入到apache bin目錄裡面有個ab.exe,壓力測試命令如下 ab.exe c 200 n 1000 2.mysql.php 如下 正常的邏輯思維,壓力增大後,導致資料庫num欄位成為負數,將下面 貼上到自己 下測試即可。在test資料庫下,...

ab壓力測試

ab命令會建立多個併發訪問執行緒,模擬多個訪問者同時對某一url位址進行訪問。它的測試目標是基於url的,因此,它既可以用來測試apache的負載壓力,也可以測試nginx lighthttp tomcat iis等其它web伺服器的壓力。ab命令對發出負載的計算機要求很低,它既不會占用很高cpu,...

壓力測試ab

首先確定下做壓力測試的工具和效能的監控工具,這個壓測的工具使用的是ab 監控工具使用的是nmon。看下linux主機上的ulimit n 的資料是多少,為改動過的是1024,最好要改的大一點。這個是linux下最大執行緒數,如果過小的話無法進行大並量的測試。ab經行壓力測試時的指令碼我用的形式為 1...