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

首頁 > 系統(tǒng) > Linux > 正文

利用ab壓力工具對(duì)服務(wù)器進(jìn)行壓力測試

2024-08-27 23:59:06
字體:
供稿:網(wǎng)友

ab是一款壓力測試功能了,我們可以模仿用戶實(shí)質(zhì)性的訪問網(wǎng)頁從而可以測試出網(wǎng)站并發(fā)能力與數(shù)據(jù)處理能力了,下面小編為各位介紹ab壓力工具對(duì)服務(wù)器進(jìn)行壓力測試的一個(gè)例子.

在使用之前,需要先確認(rèn)是否服務(wù)器安裝了Apache Http Server,如果沒有安裝,則需要先安裝:

  1. $ sudo yum install httpd 
  2. $ ab -V 
  3. This is ApacheBench, Version 2.3 <$Revision: 1430300 $> 
  4. Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ 
  5. Licensed to The Apache Software Foundation, http://www.apache.org/ 

下面是對(duì)ab工具比較常用的一些參數(shù)的解釋.

  1. aicode:~ mylxsw$ ab -h 
  2. Usage: ab [options] [http[s]://]hostname[:port]/path 
  3. Options are: 
  4.     -n requests     要執(zhí)行的請(qǐng)求數(shù)量 
  5.     -c concurrency  并發(fā)請(qǐng)求數(shù)量 
  6.     -b windowsize   TCP發(fā)送/接收緩沖區(qū)大小,單位所以byte 
  7.     -p postfile     指定POST發(fā)送的數(shù)據(jù)文件,不要忘記設(shè)置-T參數(shù) 
  8.     -u putfile      指定PUT發(fā)送的數(shù)據(jù)文件,不要忘記設(shè)置-T參數(shù) 
  9.     -T content-type 使用POST/PUT發(fā)送數(shù)據(jù)時(shí),指定Content-type請(qǐng)求頭,例如. 
  10.                     'application/x-www-form-urlencoded' 
  11.                     默認(rèn)是 'text/plain' 
  12.     -w              以HTML表格的形式輸出結(jié)果 
  13.     -i              請(qǐng)求方式使用HEAD代替GET 
  14.     -C attribute    添加Cookie,例如'Apache=1234'. (可以重復(fù)設(shè)置) 
  15.     -H attribute    添加任意的請(qǐng)求Header,例如. 'Accept-Encoding: gzip'(可重復(fù)設(shè)置) 
  16.     -A attribute    添加基本的WWW認(rèn)證信息,這個(gè)屬性是用英文逗號(hào)分隔的用戶名和密碼 
  17.     -P attribute    添加代理服務(wù)器認(rèn)證信息,使用逗號(hào)分隔用戶名和密碼 
  18.     -X proxy:port   指定代理服務(wù)器的地址和端口號(hào) 
  19.     -k              使用HTTP的KeepAlive特性 
  20.     -r              當(dāng)Socket收到錯(cuò)誤信息時(shí)不要退出. 
  21.     -Z ciphersuite  指定SSL/TLS加密套件 
  22.     -f protocol     指定SSL/TLS協(xié)議(SSL2, SSL3, TLS1 or ALL) 
  23.     ... 

假如我們需要對(duì)http://letv.com進(jìn)行壓力測試,指定請(qǐng)求總數(shù)為100,并發(fā)用戶數(shù)為10,我們可以以下面的方式進(jìn)行測試.

  1. $ ab -n 100 -c 10 http://letv.com/ 
  2. This is ApacheBench, Version 2.3 <$Revision: 1430300 $> 
  3. Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ 
  4. Licensed to The Apache Software Foundation, http://www.apache.org/ 
  5. Benchmarking letv.com (be patient).....done 
  6.  
  7. Server Software:        nginx/1.2.1 
  8. Server Hostname:        letv.com 
  9. Server Port:            80 
  10. Document Path:          / 
  11. Document Length:        184 bytes 
  12. Concurrency Level:      10 
  13. Time taken for tests:   0.396 seconds 
  14. Complete requests:      100 
  15. Failed requests:        0 
  16. Write errors:           0 
  17. Non-2xx responses:      100 
  18. Total transferred:      37300 bytes 
  19. HTML transferred:       18400 bytes 
  20. Requests per second:    252.29 [#/sec] (mean) 
  21. Time per request:       39.637 [ms] (mean) 
  22. Time per request:       3.964 [ms] (mean, across all concurrent requests) 
  23. Transfer rate:          91.90 [Kbytes/sec] received 
  24. Connection Times (ms) 
  25.               min  mean[+/-sd] median   max 
  26. Connect:        4    5   0.9      5       8 
  27. Processing:     4   33  87.4      6     312 
  28. Waiting:        4   33  87.3      5     311 
  29. Total:          9   39  87.6     12     317 
  30. Percentage of the requests served within a certain time (ms) 
  31.   50%     12  //Vevb.com 
  32.   66%     12 
  33.   75%     13 
  34.   80%     14 
  35.   90%     15 
  36.   95%    316 
  37.   98%    317 
  38.   99%    317 
  39.  100%    317 (longest request) 

需要注意的幾個(gè)字段是:

Requests per second 吞吐率(reqs/s),該字段值為252.29,該值表明了服務(wù)器每秒能夠處理的請(qǐng)求數(shù)量.

Time per request 平均請(qǐng)求處理時(shí)間,可以看到,該字段分為兩行,有兩個(gè)不同的值,代表了處理每隔請(qǐng)求所需要的時(shí)間,但是第一行的值是第二行的10倍,這是因?yàn)槲覀冎付ǖ牟l(fā)數(shù)量為10,第一行為每次并發(fā)請(qǐng)求的平均耗時(shí),第二行為每隔請(qǐng)求的耗時(shí),因此,第一行值為第二行的值乘上并發(fā)請(qǐng)求數(shù)量,可以嘗試將并發(fā)數(shù)改為20,這樣就會(huì)看到第一行是第二行的20倍.

Transfer rate 每秒從服務(wù)器獲取的數(shù)據(jù)的長度,上面的介紹的是linux中,下面來看看Windows環(huán)境下Apache服務(wù)器壓力測試工具ab使用說明.

在Apache服務(wù)器自帶了一個(gè)測試程序Ab.exe可以很方便的使用,進(jìn)入cmd,之后進(jìn)入ab.exe的目錄,命令是 ab -c 請(qǐng)求數(shù) -n 線程數(shù) 網(wǎng)址(建議輸入目標(biāo)網(wǎng)頁.

線程數(shù)不宜過大 按照你電腦的承受能力,例:ab -n 10 -c 10 http://192.168.1.3/index.html

結(jié)果如下:

  1. D:Apachebin>ab -n 10 -c 10 http://192.168.1.3/index.html  
  2. (以上是輸入的命令) 
  3. Benchmarking 192.168.1.3 (be patient).....done  
  4. Server Software:        Apache/2.0.63  
  5. (目標(biāo)服務(wù)器Apache版本號(hào)) 
  6. Server Hostname:        192.168.1.3  
  7. (目標(biāo)服務(wù)器主機(jī)頭名稱) 
  8. Server Port:            80  
  9. (目標(biāo)服務(wù)器Apache端口) 
  10. Document Path:          /index.html  
  11. (目標(biāo)網(wǎng)頁相對(duì)地址) 
  12. Document Length:        292 bytes  
  13. (目標(biāo)網(wǎng)頁大?。?nbsp;
  14. Concurrency Level:      10  
  15. (并發(fā)線程數(shù)) 
  16. Time taken for tests:   0.140625 seconds  
  17. (使用時(shí)間) 
  18. Complete requests:      10  
  19. (成功的請(qǐng)求數(shù)量) 
  20. Failed requests:        0  
  21. (失敗的請(qǐng)求數(shù)量) 
  22. Write errors:           0  
  23. (發(fā)生錯(cuò)誤數(shù)量) 
  24. Total transferred:      5750 bytes  
  25. (全部使用的流量) 
  26. HTML transferred:       2920 bytes  
  27. (Html文件使用的流量) 
  28. Requests per second:    71.11 [#/sec] (mean)  
  29. (指標(biāo)一 平均每秒請(qǐng)求數(shù)) 
  30. Time per request:       140.625 [ms] (mean)  
  31. (指標(biāo)二 平均事務(wù)響應(yīng)時(shí)間) 
  32. Time per request:       14.063 [ms] (mean, across all concurrent requests)  
  33. (每秒請(qǐng)求時(shí)間) 
  34. Transfer rate:          35.56 [Kbytes/sec] received  
  35. (傳輸速率) 
  36. Connection Times (ms)  
  37.              min  mean[+/-sd] median   max  
  38. Connect:        0    0   0.0      0       0  
  39. Processing:   109  124  16.3    140     140  
  40. Waiting:      109  124  16.3    140     140  
  41. Total:        109  124  16.3    140     140  
  42. (所有請(qǐng)求的響應(yīng)情況) 
  43. Percentage of the requests served within a certain time (ms)  
  44. 50%    140  
  45. 66%    140  
  46. 75%    140  
  47. 80%    140  
  48. 90%    140  
  49. 95%    140  
  50. 98%    140  
  51. 99%    140  
  52. 100%    140 (longest request) 

每個(gè)請(qǐng)求都有一個(gè)響應(yīng)時(shí)間,比如 其中 50% 的用戶響應(yīng)時(shí)間小于 140 毫秒,最大的響應(yīng)時(shí)間小于 140 毫秒(100% 處).

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 紫云| 青神县| 进贤县| 神池县| 上高县| 龙山县| 宿迁市| 弋阳县| 敦煌市| 临夏市| 皮山县| 喀喇| 甘肃省| 澄迈县| 巴彦淖尔市| 靖西县| 山东| 菏泽市| 睢宁县| 潞城市| 株洲市| 贡山| 台中市| 宁安市| 青岛市| 永善县| 建平县| 温州市| 阿城市| 阜康市| 普定县| 佳木斯市| 昌吉市| 衡山县| 新安县| 余干县| 扶余县| 四子王旗| 靖远县| 桐城市| 鹤壁市|