壓測工具ab的簡單使用

2022-07-21 18:45:15 字數 2345 閱讀 5114

apache benchmark(ab)是一種常見的壓測工具,不僅可以對apache進行壓測,也可以對nginx,tomcat,iis等進行壓測

安裝如果安裝了apache,那麼ab已經自帶了,不需要再額外安裝,如果沒有安裝apache,可以通過以下方式安裝

壓測在壓測前,需要關注幾個選項,通過ab --help檢視

-n  requests       要執行的請求次數

-c concurrency 併發數量

-s timeout 響應時間

#### 執行

執行以下**進行壓測

ab -n 1000 -c 100 -s 1 

# 一共1000個請求,併發100,超時時間為1s,後面為測試的url

測試結果

apr_pollset_poll: the timeout specified has expired (70007)

total of 997 requests completed

顯示有997個請求完成了,而且報錯了,說明有請求超過1s,所以把超時時間去掉重新測試

ab -n 1000 -c 100

結果

server software:        nginx/x.x.x

server hostname: www.my.com

server port: 80

document path: /

document length: 2368 bytes

concurrency level: 100

time taken for tests: 30.914 seconds

complete requests: 1000

failed requests: 0

write errors: 0

total transferred: 2527000 bytes

html transferred: 2368000 bytes

requests per second: 32.35 [#/sec] (mean)

time per request: 3091.393 [ms] (mean)

time per request: 30.914 [ms] (mean, across all concurrent requests)

transfer rate: 79.83 [kbytes/sec] received

connection times (ms)

min mean[+/-sd] median max

connect: 0 174 381.6 0 2006

processing: 1 2391 6166.6 205 25853

waiting: 1 2080 5941.6 205 25853

total: 2 2565 6143.6 406 26609

percentage of the requests served within a certain time (ms)

50% 406

66% 1004

75% 1413

80% 1616

90% 6448

95% 25760

98% 25824

99% 25855

100% 26609 (longest request)

這裡我們需要關注以下幾個資料

1)failed requests:失敗的請求

2)requests per second:也就是常說的qps, 每秒查詢率,這是乙個平均值

3)time per request:完成乙個請求所花費的時間

4)transfer rate: 網路傳輸速度。對於大檔案的請求測試,這個值很容易成為系統瓶頸所在要確定該值是不是瓶頸,需要了解客戶端和被測伺服器之間的網路情況,包括網路頻寬和網絡卡速度等資訊。

ab壓測工具

root localhost yum install y httpd tools 安裝ab工具 root localhost ab c 10 n 1000 指定併發請求數為10,總請求數為1000,對進行壓力測試 this is apachebench,version 2.3 revision 14...

壓測工具 ab

使用 其中,c表示併發數為10,n表示總請求個數為1000,p表示請求的資料放在了post.txt中,t表示請求的格式,http.表示待測試的伺服器。效能壓力測試是伺服器 效能調優過程中必不可缺少的一環。只有讓伺服器處在高壓情況下,才能真正體現出軟體 硬體等各種設定不當所暴露出的問題。效能測試工具目...

AB 壓測工具命令

n 即requests,用於指定壓力測試總共的執行次數。c 即concurrency,用於指定的併發數。t 即timelimit,等待響應的最大時間 單位 秒 b 即windowsize,tcp傳送 接收的緩衝大小 單位 位元組 p 即postfile,傳送post請求時需要上傳的檔案,此外還必須設...