<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          get、post請(qǐng)求使用ab工具如何做并發(fā)測(cè)試

          共 7395字,需瀏覽 15分鐘

           ·

          2020-07-28 12:13

          最近確實(shí)也有些忙,原來都是利用周末的時(shí)間寫東西,現(xiàn)在周末的時(shí)間被占滿,照顧小孩。只能忙中找空,寫點(diǎn)東西。

          最近正好使用ab性能測(cè)試工具測(cè)了一個(gè)項(xiàng)目,主要用來做并發(fā)測(cè)試,需求是控制水軍用戶的并發(fā)數(shù),通過nginx配置控制并發(fā)量(針對(duì)異常ip--雙ip),所以為了能夠快速上線,就選擇了ab工具。覺得ab工具多多少少還是可以快速的運(yùn)用到工作當(dāng)中,所以有必要寫出來分享給需要的同行。主要介紹下使用ab工具并發(fā)發(fā)送get和post請(qǐng)求,比如日常工具中做并發(fā)測(cè)試可以使用(針對(duì)活動(dòng)等相關(guān)庫存的并發(fā)測(cè)試)

          linux下安裝ab性能測(cè)試工具

          1. yum -y install httpd-tools

          安裝完成后,執(zhí)行:

          1. ab -H 'X-Forwarded-For:2.2.2.2' -n 100 -c 30 http://m.1768.com/?act=index&st=login

          備注:

          2.2.2.2為模擬的ip

          查看nginx訪問日志:

          1. m.1768.com 21.58.201.31 - - [18/Sep/2017:18:57:43 +0800] "GET /?act=index&st=login HTTP/1.0" 200 266 "-" "ApacheBench/2.3" 2.2.2.2,47.94.13.33

          執(zhí)行結(jié)果如下:

          1. [root@iZ9q9Z /]# ab -H 'X-Forwarded-For:2.2.2.2' -n 100 -c 30 http://m.1768.com/?

          2. act=index&st=login

          3. [1] 4515

          4. [root@iZ9otb9Z /]# This is ApacheBench, Version 2.3 <$Revision: 1430300 $>

          5. Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

          6. Licensed to The Apache Software Foundation, http://www.apache.org/

          7. Benchmarking 10test7-admin.stg3.1768.com (be patient).....done

          8. Server Software: ? ? ? ?nginx

          9. Server Hostname: ? ? ? ?m.1768.com

          10. Server Port: ? ? ? ? ? ?80

          11. Document Path: ? ? ? ? ?/?act=index ? ?#請(qǐng)求的資源

          12. Document Length: ? ? ? ?0 bytes ? ? #文檔返回的長(zhǎng)度,不包括相應(yīng)的頭

          13. Concurrency Level: ? ? ?30 ? ? ? ? ?#并發(fā)數(shù)

          14. Time taken for tests: ? 0.609 seconds ? #總請(qǐng)求時(shí)長(zhǎng)

          15. Complete requests: ? ? ?100 ? ? ? ? ? ?#總請(qǐng)求數(shù)

          16. Failed requests: ? ? ? ?0 ? ? ? ? ? #失敗的請(qǐng)求數(shù)

          17. Write errors: ? ? ? ? ? 0 ? ? ? ? ?#錯(cuò)誤

          18. Non-2xx responses: ? ? ?100

          19. Total transferred: ? ? ?45900 bytes ? #總共傳輸數(shù)據(jù)量

          20. HTML transferred: ? ? ? 0 bytes

          21. Requests per second: ? ?164.18 [#/sec] (mean) ? #平均每秒的請(qǐng)求數(shù),重要指標(biāo):相當(dāng)于LR中的每秒事務(wù)數(shù),后面的括號(hào)中mean表示這是一個(gè)平均值

          22. Time per request: ? ? ? 182.725 [ms] (mean) ? ?#平均每個(gè)請(qǐng)求消耗的時(shí)間,重要指標(biāo):LR中的平均事務(wù)響應(yīng)時(shí)間

          23. Time per request: ? ? ? 6.091 [ms] (mean, across all concurrent requests) ? #上面的請(qǐng)求除以并發(fā)數(shù),即服務(wù)器平均請(qǐng)求響應(yīng)時(shí)間 在并發(fā)量為1時(shí) 用戶等待時(shí)間相同 ?

          24. Transfer rate: ? ? ? ? ?73.59 [Kbytes/sec] received ? #平均每秒多少K,即傳輸速率

          25. Connection Times (ms)

          26. ? ? ? ? ? ? ?min ?mean[+/-sd] median ? max

          27. Connect: ? ? ? 28 ? 32 ? 1.7 ? ? 32 ? ? ?36

          28. Processing: ? ?70 ?106 ?25.5 ? ?100 ? ? 169

          29. Waiting: ? ? ? 70 ?106 ?25.5 ? ?100 ? ? 169

          30. Total: ? ? ? ?100 ?138 ?25.7 ? ?134 ? ? 202

          31. Percentage of the requests served within a certain time (ms)

          32. ?50% ? ?134 ? ? ? ?#50%的請(qǐng)求都在134ms內(nèi)完成

          33. ?66% ? ?143

          34. ?75% ? ?153

          35. ?80% ? ?163

          36. ?90% ? ?180

          37. ?95% ? ?188

          38. ?98% ? ?193

          39. ?99% ? ?202

          40. 100% ? ?202 (longest request)

          具體每個(gè)參數(shù)的含義可以參考如下地址,里面有很詳細(xì)的介紹。

          1. http://www.jb51.net/article/59469.htm

          舉例

          get請(qǐng)求

          1. ab -H 'X-Forwarded-For:2.2.2.2' -n 100 -c 10 -C "Cookie: appId=3793; track_u_3793=CS1111QXZ591F5C6066AACC1B57273B8; popbeforelogin=aToxOw%3D%3D; Hm_lvt_a52c9eb6cde4f51aa1212ed955bc723c=1504493440,1504503826,1504580247,1505092652; Hm_lpvt_a52c9eb6cde4f51aa1212ed955bc723c=1505121635; YOUXISID=88811fde2b2d2648ae4b4ddefa7da6f28530cb2a; is_visitor=0; point_games_flag_v9_game_circus_5252037600830=2037600830; exchangeReturnUrl=%2F%3Fact%3Dgame_collection; ucenter=newucenter; newucenter_nologout=1; tExchangeBackUrl=newucenter; PHPSESSID=5vqp5j4knn6mldjqt2fovc3ad5; track_u_3783=37yoo; track_u=37yoo; point_games_flag_v9_pinballwap_5252037600830=2037600830; gameHistoryRecord=a%3A3%3A%7Bi%3A0%3Bi%3A3697%3Bi%3A1%3Bi%3A3783%3Bi%3A2%3Bi%3A3793%3B%7D; tExchangeBacToGame=%2F%3Fact%3Dpinballwap; loginReturnUrl=%2F%3Fact%3Dpinballwap%26track_u%3D37yoo; Hm_lvt_be49684f9d9c2de3c96227f9e25c261b=1503630548,1505359432; Hm_lpvt_be49684f9d9c2de3c96227f9e25c261b=1505375090; Hm_lvt_70e5a3dba732ce8be082655aff6ff1e6=1503455932,1504839932,1505186995; Hm_lpvt_70e5a3dba732ce8be082655aff6ff1e6=1505375091" "http://m.1768.com/?act=pinballwap&act=pinballwap&st=play_once&amount=500&newer=1&rndnum=599719"

          備注:

          1.cookie內(nèi)容一定要加個(gè)雙引號(hào);
          2.請(qǐng)求url加雙引號(hào);

          post請(qǐng)求

          1. ab -H 'X-Forwarded-For:2.2.2.2' -n 1000 -c 100 -p /root/circus.txt -T application/x-www-form-urlencoded -C "Cookie: appId=3793; track_u_3793=CS1111QXZ591F5C6066AACC1B57273B8; popbeforelogin=aToxOw%3D%3D; track_u_3783=37yoo; YOUXISID=14fe43e78bd2e7e41934ac8e9fc809ed881af5fd; is_visitor=0; exchangeReturnUrl=%2F%3Fact%3Dgame_collection; track_u=37yoo; ucenter=newucenter; newucenter_nologout=1; tExchangeBackUrl=newucenter; point_games_flag_v9_game_circus_5252037600830=2037600830; PHPSESSID=5vqp5j4knn6mldjqt2fovc3ad5; gameHistoryRecord=a%3A3%3A%7Bi%3A0%3Bi%3A3783%3Bi%3A1%3Bi%3A3697%3Bi%3A2%3Bi%3A3793%3B%7D; tExchangeBacToGame=%2F%3Fact%3Dgame_circus; loginReturnUrl=%2F%3Fact%3Dgame_circus; Hm_lvt_be49684f9d9c2de3c96227f9e25c261b=1503630548,1505359432; Hm_lpvt_be49684f9d9c2de3c96227f9e25c261b=1505469850; Hm_lvt_70e5a3dba732ce8be082655aff6ff1e6=1503455932,1504839932,1505186995; Hm_lpvt_70e5a3dba732ce8be082655aff6ff1e6=1505469852" "http://m.1768.com/?index.php"

          circus.txt文件中保存的參數(shù)格式:
          1. act=game_circus&st=start&amount=1300&isNewUser=0&autoBetFlag=0

          執(zhí)行結(jié)果如下:

          1. [root@iz2zfd6z ~]# ab -H 'X-Forwarded-For:2.2.2.2' -n 1000 -c 100 -C "Cookie: appId=3793; track_u_3793=CS1111QXZ591F5C6066AACC1B57273B8; popbeforelogin=aToxOw%3D%3D; track_u_3783=37yoo; YOUXISID=14fe43e78bd2e7e41934ac8e9fc809ed881af5fd; is_visitor=0; exchangeReturnUrl=%2F%3Fact%3Dgame_collection; track_u=37yoo; ucenter=newucenter; newucenter_nologout=1; tExchangeBackUrl=newucenter; point_games_flag_v9_game_circus_5252037600830=2037600830; PHPSESSID=5vqp5j4knn6mldjqt2fovc3ad5; gameHistoryRecord=a%3A3%3A%7Bi%3A0%3Bi%3A3783%3Bi%3A1%3Bi%3A3697%3Bi%3A2%3Bi%3A3793%3B%7D; tExchangeBacToGame=%2F%3Fact%3Dgame_circus; loginReturnUrl=%2F%3Fact%3Dgame_circus; Hm_lvt_be49684f9d9c2de3c96227f9e25c261b=1503630548,1505359432; Hm_lpvt_be49684f9d9c2de3c96227f9e25c261b=1505469850; Hm_lvt_70e5a3dba732ce8be082655aff6ff1e6=1503455932,1504839932,1505186995; Hm_lpvt_70e5a3dba732ce8be082655aff6ff1e6=1505469852" -p /root/circus.txt -T application/x-www-form-urlencoded "http://m.1768.com/?index.php"

          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 10test7-wap.stg3.1768.com (be patient)

          6. Completed 100 requests

          7. Completed 200 requests

          8. Completed 300 requests

          9. Completed 400 requests

          10. Completed 500 requests

          11. Completed 600 requests

          12. Completed 700 requests

          13. Completed 800 requests

          14. Completed 900 requests

          15. Completed 1000 requests

          16. Finished 1000 requests

          17. Server Software: ? ? ? ?nginx

          18. Server Hostname: ? ? ? ?10test7-wap.stg3.1768.com

          19. Server Port: ? ? ? ? ? ?80

          20. Document Path: ? ? ? ? ?/?index.php

          21. Document Length: ? ? ? ?267 bytes

          22. Concurrency Level: ? ? ?100

          23. Time taken for tests: ? 13.657 seconds

          24. Complete requests: ? ? ?1000

          25. Failed requests: ? ? ? ?993

          26. ? (Connect: 0, Receive: 0, Length: 993, Exceptions: 0)

          27. Write errors: ? ? ? ? ? 0

          28. Total transferred: ? ? ?365377 bytes

          29. Total body sent: ? ? ? ?1098000

          30. HTML transferred: ? ? ? 102377 bytes

          31. Requests per second: ? ?73.22 [#/sec] (mean)

          32. Time per request: ? ? ? 1365.722 [ms] (mean)

          33. Time per request: ? ? ? 13.657 [ms] (mean, across all concurrent requests)

          34. Transfer rate: ? ? ? ? ?26.13 [Kbytes/sec] received

          35. ? ? ? ? ? ? ? ? ? ? ? ?78.51 kb/s sent

          36. ? ? ? ? ? ? ? ? ? ? ? ?104.64 kb/s total

          37. Connection Times (ms)

          38. ? ? ? ? ? ? ?min ?mean[+/-sd] median ? max

          39. Connect: ? ? ? 25 ? 45 125.7 ? ? 29 ? ?1037

          40. Processing: ? 115 ?911 1246.9 ? ?637 ? ?8654

          41. Waiting: ? ? ?115 ?911 1246.9 ? ?637 ? ?8654

          42. Total: ? ? ? ?146 ?957 1248.8 ? ?675 ? ?8683

          43. Percentage of the requests served within a certain time (ms)

          44. ?50% ? ?675

          45. ?66% ? ?834

          46. ?75% ? 1028

          47. ?80% ? 1117

          48. ?90% ? 1476

          49. ?95% ? 3128

          50. ?98% ? 7552

          51. ?99% ? 7636

          52. 100% ? 8683 (longest request)

          至于用作性能分析建議還是使用LR,有興趣也可以對(duì)性能結(jié)果進(jìn)行分析。

          python爬蟲人工智能大數(shù)據(jù)公眾號(hào)




          瀏覽 95
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  黄片免费在线播放 | 看国内看国内黄色一级片和国产麻豆 | 婷婷五月天大香蕉 | PANS私拍在线一区二区 | 翔田千里与黑人未删减avXX |