linux AB web 性能測試工具

ab(選項)(參數)

選項

-A:指定鏈接服務器的基本的認證憑據;
-c:指定一次向服務器發出請求數;
-C:添加cookie;
-g:將測試結果輸出爲「gnuolot」文件;
-h:顯示幫助信息;
-H:爲請求追加一個額外的頭;
-i:使用「head」請求方式;
-k:激活HTTP中的「keepAlive」特性;
-n:指定測試會話使用的請求數;
-p:指定包含數據的文件;
-q:不顯示進度百分比;
-T:使用POST數據時,設置內容類型頭;
-v:設置詳細模式等級;
-w:以HTML表格方式打印結果; -x:以表格方式輸出時,設置表格的屬性; -X:使用指定的代理服務器發送請求; -y:以表格方式輸出時,設置表格屬性。

安裝nginx 以及tomcat
192.168.10.145 nginx
192.168.10.135 tomcat

[root@localhost code]# cat /etc/nginx/conf.d/jsp.conf 
server {
server_name local;
listen 80;
location / {
root /soft/code;
try_files $uri @java_page;
index index.jsp index.html;
}
location @java_page{
proxy_pass http://192.168.10.135:8080;
}
}html

nginx  的test.htmljava

 

tomcat 的test.htmllinux

 

nginx 性能測試nginx

Server Software: nginx/1.14.0  ##nginx 版本
Server Hostname: 192.168.10.145  #IP
Server Port: 80   #監聽端口tomcat

Document Path: /test.html  #請求源
Document Length: 19 bytes  #文檔返回的長度,不包括頭部服務器

Concurrency Level: 1000  #併發個數
Time taken for tests: 0.311 seconds  #總請求時間
Complete requests: 1000  #請求個數
Failed requests: 0  #請求失敗個數
Write errors: 0   
Total transferred: 250000 bytes 
HTML transferred: 19000 bytes
Requests per second: 3216.98 [#/sec] (mean)    ###平均每秒的請求數
Time per request: 310.851 [ms] (mean)    #平均每一個請求消耗的時間
Time per request: 0.311 [ms] (mean, across all concurrent requests)  #上面的請求除以併發數
Transfer rate: 785.39 [Kbytes/sec] received   #傳輸速率cookie

移除nginx當前的test頁面, 讓nginx經過代理請求到tomcat的test.html併發

Server Software: nginx/1.14.0
Server Hostname: 192.168.10.145
Server Port: 80jsp

Document Path: /test.html
Document Length: 27 bytes性能

Concurrency Level: 1000
Time taken for tests: 3.398 seconds
Complete requests: 1000
Failed requests: 118
(Connect: 0, Receive: 0, Length: 118, Exceptions: 0)
Write errors: 0
Non-2xx responses: 118
Total transferred: 275620 bytes
HTML transferred: 46588 bytes
Requests per second: 294.32 [#/sec] (mean)
Time per request: 3397.638 [ms] (mean)
Time per request: 3.398 [ms] (mean, across all concurrent requests)
Transfer rate: 79.22 [Kbytes/sec] received

 

 

 

 這樣就能夠對比當前nginx所面臨的壓力,能夠針對性的進行調優。

相關文章
相關標籤/搜索