壓力測試Jmeter+badboy
前言:不少人都想學習壓力測試,可是一開始手動寫腳本着實蛋疼,因此今天我教你們的是利用badboy來錄製壓測腳本,而後用Jmeter來作壓力測試。
流程:badboy導出Jmeter壓測腳本->Jmeter進行壓力測試(特別適用於本次潘sir大做業–電影售票系統web版本的壓力測試)
第一步:下載badboy和Jmeter
badboy:http://www.badboy.com.au/
Jmeter:http://jmeter.apache.org/web
安裝特別簡單,筆者羅煒勁也沒遇到什麼困難。這裏就不贅述了,真的沒坑的,也不須要配置什麼。可能惟一須要注意的是Jmeter的運行,須要打開bin目錄下的批處理文件:看下面截圖。apache
![這裏寫圖片描述](http://static.javashuo.com/static/loading.gif)
會首先出現一個命令行,而後出現如下圖形化界面服務器
![這裏寫圖片描述](http://static.javashuo.com/static/loading.gif)
第二步,用badboy錄製腳本並導出.jmx格式
筆者這裏隨便拿某訊的網站來示範,固然,人家的機制確定是會防止別人ddos攻擊,因此頻繁發出請求的話,確定是會返回拒絕訪問的結果,可是咱們不關注返回結果,我麼關注錄製和壓測的流程。併發
首先在地址欄輸入要壓測的地址而後跳轉
![這裏寫圖片描述](http://static.javashuo.com/static/loading.gif)
這時候badboy左側腳本已經錄製一條了,能夠看到頁面已經跳轉到了QQ郵箱,而且script多了一條記錄
![這裏寫圖片描述](http://static.javashuo.com/static/loading.gif)
而後輸入帳號密碼,點擊登陸,頁面跳轉,同時腳本多一個步驟
![這裏寫圖片描述](http://static.javashuo.com/static/loading.gif)
而後我就退出了QQ郵箱。而且,腳本多了一行
![這裏寫圖片描述](http://static.javashuo.com/static/loading.gif)
錄製完成以後,點擊左上角的導出jmeter,保存腳本到指定目錄。
![這裏寫圖片描述](http://static.javashuo.com/static/loading.gif)
第三步:Jmeter出場
首先打開剛剛從badboy哪裏保存的腳本
![這裏寫圖片描述](http://static.javashuo.com/static/loading.gif)
能夠看到測試計劃多了一個,而後線程組就是定義併發數目,step就是壓測的步驟,意思就是好比1000個併發,就會模擬1000我的,不斷重複剛剛我錄製的操做,登陸郵箱,退出郵箱這樣。
![這裏寫圖片描述](http://static.javashuo.com/static/loading.gif)
雙擊Thread Group線程組,就能夠定義線程數,循環次數,隨機間隔時間。想作壓力測試,固然線程數越多壓力越大,間隔越小越大。
![這裏寫圖片描述](http://static.javashuo.com/static/loading.gif)
第四步:壓測步驟已經寫好,是否是能夠直接運行呢?咱們還須要添加監聽器!來查看壓測返回的結果啊!
![這裏寫圖片描述](http://static.javashuo.com/static/loading.gif)
監聽器的種類好多,能夠所有加進去試試,各有各的看點!我加了三個監聽器:
![這裏寫圖片描述](http://static.javashuo.com/static/loading.gif)
最後,運行!查看結果
查看結果樹
![這裏寫圖片描述](http://static.javashuo.com/static/loading.gif)
表格查看
![這裏寫圖片描述](http://static.javashuo.com/static/loading.gif)
聚合報告:我喜歡看這個,能夠看出錯誤率,最大吞吐量。能夠反映出服務器性能。
![這裏寫圖片描述](http://static.javashuo.com/static/loading.gif)