PHP壓力測試 ab.exe的使用 及 更改mpm的最大並發數

來源:互聯網
上載者:User

一:ab.exe的使用
ab.exe是Apache附帶的壓力測試工具,可以在web伺服器本地類比發起測試請求

1:進入Apache的bin目錄

#輸入命令ab.exe -n 1000 -c 100 http://localhost/test/index.php;

index.php

<?php#用迴圈來類比處理商務邏輯for($i = 0; $i <= 100; $i++) {    echo $i . '|';}

CMD測試資料

Server Software:        Apache/2.4.23Server Hostname:        localhostServer Port:            80Document Path:          /index.php;Document Length:        208 bytesConcurrency Level:      100Time taken for tests:   0.314 seconds   #訪問的總時間Complete requests:      1000            #訪問的總次數Failed requests:        0               #失敗的訪問次數Non-2xx responses:      1000            Total transferred:      418000 bytesHTML transferred:       208000 bytesRequests per second:    3182.42 [#/sec] (mean)   #每秒訪問多少次Time per request:       31.423 [ms] (mean)    #這麼多人(100人)訪問一次的時間Time per request:       0.314 [ms] (mean, across all concurrent requests)Transfer rate:          1299.07 [Kbytes/sec] receivedConnection Times (ms)              min  mean[+/-sd] median   maxConnect:        0    0   0.3      0       1Processing:     6   30   4.5     31      46Waiting:        3   22   6.2     23      39Total:          6   30   4.5     31      46Percentage of the requests served within a certain time (ms)  50%     31  66%     32  75%     32  80%     32  90%     33  95%     34  98%     37  99%     37 100%     46 (longest request)

2、增大並發數到500

ab.exe -n 10000 -c 500 http://localhost/test/index.php;

會出現下面的情況

Benchmarking localhost (be patient)Completed 1000 requestsTest aborted after 10 failuresapr_socket_connect(): 由於目標電腦積極拒絕,無法串連。   (730061)Total of 1299 requests completed

是因為Apache預設的最大並發數是150
可以更改conf/extra/httpd-mpm.conf來更改最大並發數

二:
開啟httpd.conf設定檔,開啟下面的配置

# Server-poolmanagement (MPM specific)Include conf/extra/httpd-mpm.conf

在apache/bin 目錄下 輸入

httpd.exe -l;

顯示

Compiled in modules:  core.c  mod_win32.c  mpm_winnt.c     #說明是winnt模式  http_core.c  mod_so.c

開啟conf/extra/httpd-mpm.conf檔案
找到

<IfModule mpm_winnt_module>    ThreadsPerChild      150     #改成1000即可    MaxRequestsPerChild    3000   </IfModule>

重啟伺服器,重新運行

ab.exe -n 10000 -c 500 http://localhost/test/index.php;

會出現相似的結果

如果是其它模式,更改httpd-mpm.conf對應的位置即可

<IfModule mpm_prefork_module>     StartServers             5                  #開始啟動的進程     MinSpareServers          5                  #最小準備進程     MaxSpareServers         10                  #最大空閑進程     MaxRequestWorkers      1000                 #最大並發數     MaxConnectionsPerChild   0  </IfModule>  
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.