国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 網(wǎng)站 > Apache > 正文

使用Apache ab工具對(duì)Apache服務(wù)器進(jìn)行簡(jiǎn)單的壓力測(cè)試

2024-08-27 18:30:27
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
這篇文章主要介紹了使用Apache ab工具對(duì)Apache服務(wù)器進(jìn)行簡(jiǎn)單的壓力測(cè)試的方法,文中還對(duì)如何查看當(dāng)前Apache的連接數(shù)的方法作了介紹,需要的朋友可以參考下
 

1.安裝ab命令

sudo apt-get install apache2-utils 

2.ab命令參數(shù)說(shuō)明

Usage: ab [options] [http[s]://]hostname[:port]/path  
Options are:  
  

//總的請(qǐng)求數(shù)  -n requests Number of requests to perform  //一次同時(shí)并發(fā)的請(qǐng)求數(shù) 總的請(qǐng)求數(shù)(n)=次數(shù)*一次并發(fā)數(shù)(c)  -c concurrency Number of multiple requests to make 

-n requests Number of requests to perform
//在測(cè)試會(huì)話中所執(zhí)行的請(qǐng)求個(gè)數(shù)(本次測(cè)試總共要訪問(wèn)頁(yè)面的次數(shù))。默認(rèn)時(shí),僅執(zhí)行一個(gè)請(qǐng)求。
-c concurrency Number of multiple requests to make
//一次產(chǎn)生的請(qǐng)求個(gè)數(shù)(并發(fā)數(shù))。默認(rèn)是一次一個(gè)。
-t timelimit Seconds to max. wait for responses
//測(cè)試所進(jìn)行的最大秒數(shù)。其內(nèi)部隱含值是-n 50000。它可以使對(duì)服務(wù)器的測(cè)試限制在一個(gè)固定的總時(shí)間以內(nèi)。默認(rèn)時(shí),沒有時(shí)間限制。
-p postfile File containing data to POST
//包含了需要POST的數(shù)據(jù)的文件,文件格式如“p1=1&p2=2”.使用方法是 -p 111.txt 。 (配合-T)
-T content-type Content-type header for POSTing
//POST數(shù)據(jù)所使用的Content-type頭信息,如 -T “application/x-www-form-urlencoded” 。 (配合-p)
-v verbosity How much troubleshooting info to print
//設(shè)置顯示信息的詳細(xì)程度 – 4或更大值會(huì)顯示頭信息, 3或更大值可以顯示響應(yīng)代碼(404, 200等), 2或更大值可以顯示警告和其他信息。 -V 顯示版本號(hào)并退出。
-w Print out results in HTML tables
//以HTML表的格式輸出結(jié)果。默認(rèn)時(shí),它是白色背景的兩列寬度的一張表。
-i Use HEAD instead of GET
// 執(zhí)行HEAD請(qǐng)求,而不是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. -C “c1=1234,c2=2,c3=3″ (repeatable)
//-C cookie-name=value 對(duì)請(qǐng)求附加一個(gè)Cookie:行。 其典型形式是name=value的一個(gè)參數(shù)對(duì)。此參數(shù)可以重復(fù),用逗號(hào)分割。
提示:可以借助session實(shí)現(xiàn)原理傳遞 JSESSIONID參數(shù), 實(shí)現(xiàn)保持會(huì)話的功能,如
-C ” c1=1234,c2=2,c3=3, JSESSIONID=FF056CD16DA9D71CB131C1D56F0319F8″ 。
-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 對(duì)一個(gè)中轉(zhuǎn)代理提供BASIC認(rèn)證信任。用戶名和密碼由一個(gè):隔開,并以base64編碼形式發(fā)送。無(wú)論服務(wù)器是否需要(即, 是否發(fā)送了401認(rèn)證需求代碼),此字符串都會(huì)被發(fā)送。
-X proxy:port Proxyserver and port number to use
-V Print version number and exit
-k Use HTTP KeepAlive feature
-d Do not show percentiles served table.
-S Do not show confidence estimators and warnings.
-g filename Output collected data to gnuplot format file.
-e filename Output CSV file with percentages served
-h Display usage information (this message)
//-attributes 設(shè)置屬性的字符串. 缺陷程序中有各種靜態(tài)聲明的固定長(zhǎng)度的緩沖區(qū)。另外,對(duì)命令行參數(shù)、服務(wù)器的響應(yīng)頭和其他外部輸入的解析也很簡(jiǎn)單,這可能會(huì)有不良后果。它沒有完整地實(shí)現(xiàn) HTTP/1.x; 僅接受某些'預(yù)想'的響應(yīng)格式。 strstr(3)的頻繁使用可能會(huì)帶來(lái)性能問(wèn)題,即你可能是在測(cè)試ab而不是服務(wù)器的性能。

3.運(yùn)行

 ab -n 100 -c 10 http://www.survivalescaperooms.com/ 

對(duì) http://www.survivalescaperooms.com/ 進(jìn)行100次請(qǐng)求,10個(gè)并發(fā)請(qǐng)求壓力測(cè)試結(jié)果。

Server Software: lighttpd/1.4.20 Server Hostname: www.survivalescaperooms.com Server Port: 80  Document Path: / Document Length: 2095 bytes  Concurrency Level: 10  //整個(gè)測(cè)試持續(xù)的時(shí)間  Time taken for tests: 3.303 seconds  //完成的請(qǐng)求數(shù)量  Complete requests: 100 Failed requests: 0 Write errors: 0 Total transferred: 235200 bytes HTML transferred: 209500 bytes  //平均每秒處理30個(gè)請(qǐng)求  Requests per second: 30.27 [#/sec] (mean)  //平均每個(gè)請(qǐng)求處理時(shí)間為330毫秒 注:這里將一次10個(gè)并發(fā)請(qǐng)求看成一個(gè)整體  Time per request: 330.335 [ms] (mean)  //平均每個(gè)并發(fā)請(qǐng)求處理 時(shí)間 為33毫秒  Time per request: 33.034 [ms] (mean, across all concurrent requests) Transfer rate: 69.53 [Kbytes/sec] received  Connection Times (ms) min mean[+/-sd] median max Connect: 51 170 35.9 178 230 Processing: 60 153 64.5 121 263 Waiting: 55 148 64.4 115 258 Total: 235 322 59.9 299 437  Percentage of the requests served within a certain time (ms)  //在這100個(gè)請(qǐng)求中有50%在299毫秒內(nèi)完成  50% 299  //在這100個(gè)請(qǐng)求中有66%在312毫秒內(nèi)完成  66% 312 75% 383 80% 412 90% 431 95% 432 98% 436 99% 437 100% 437 (longest request) 

PS:如何查看當(dāng)前Apache的連接數(shù)
查看了連接數(shù)和當(dāng)前的連接數(shù)

netstat -ant | grep $ip:80 | wc -l  netstat -ant | grep $ip:80 | grep EST | wc -l  

查看IP訪問(wèn)次數(shù)

netstat -nat|grep ":80"|awk '{print $5}' |awk -F: '{print $1}' | sort| uniq -c|sort -n 

Linux命令:

netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}' watch "netstat -n | awk '/^tcp/ {++S[/$NF]} END {for(a in S) print a, S[a]}'" 

返回結(jié)果示例:

LAST_ACK 5SYN_RECV 30ESTABLISHED 1597FIN_WAIT1 51FIN_WAIT2 504TIME_WAIT 1057

說(shuō)明:
SYN_RECV 表示正在等待處理的請(qǐng)求數(shù);
ESTABLISHED 表示正常數(shù)據(jù)傳輸狀態(tài);
TIME_WAIT 表示處理完畢,等待超時(shí)結(jié)束的請(qǐng)求數(shù);
FIN_WAIT1 表示server端主動(dòng)要求關(guān)閉tcp連接;
FIN_WAIT2 表示客戶端中斷連接;
LAST_ACK 關(guān)閉一個(gè)TCP連接需要從兩個(gè)方向上分別進(jìn)行關(guān)閉,雙方都是通過(guò)發(fā)送FIN來(lái)表示單方向數(shù)據(jù)的關(guān)閉,當(dāng)通信雙方發(fā)送了最后一個(gè)FIN的時(shí)候,發(fā)送方此時(shí)處于LAST_ACK狀態(tài),當(dāng)發(fā)送方收到對(duì)方的確認(rèn)(Fin的Ack確認(rèn))后才真正關(guān)閉整個(gè)TCP連接;



發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 兴业县| 眉山市| 松溪县| 林芝县| 白玉县| 江阴市| 剑川县| 三门峡市| 宝丰县| 鄂伦春自治旗| 晋州市| 高阳县| 宝山区| 电白县| 九龙城区| 马山县| 精河县| 哈密市| 呼玛县| 扬中市| 运城市| 麻阳| 丹棱县| 衡山县| 曲阳县| 寿宁县| 钟山县| 九龙坡区| 桐乡市| 宁化县| 陆丰市| 新蔡县| 八宿县| 大竹县| 武汉市| 镇巴县| 淮北市| 沙坪坝区| 天峻县| 金溪县| 克拉玛依市|