本文轉自:www.shuijingwanwq.com/2017/04/18/1568/
1、基於AB測試工具進行高並發情形下的模擬測試,打開:http://httpd.apache.org/docs/current/platform/windows.html#down,如下圖
2、選擇ApacheHaus,下載,2.4版本的x64的二進制文件,如下圖
3、下載文件名為:httpd-2.4.25-x64-vc14-r1.zip,如下圖
4、解壓縮之后,將Apache24復制至C:\Apache24,如下圖
5、在 cmd 中進入目錄:C:\Apache24\bin,運行命令:httpd -k install,將Apache安裝為一個服務,報錯:無法啟動此程序,因為丟失 VCRUNTIME140.dll。嘗試重新安裝該程序以解決此問題。如下圖
6、安裝Visual C++ 2015、Visual C++ 2015 x64,如下圖
7、在 cmd 中進入目錄:C:\Apache24\bin,運行命令:httpd -k install,將Apache安裝為一個服務,報錯:。如下圖
Installing the ‘Apache2.4’ service
(OS 5)拒絕訪問。 : AH00369: Failed to open the Windows service manager, perhaps you forgot to log in as Adminstrator?
8、右鍵 Windows 圖標,打開命令提示符(管理員),如下圖
9、再次安裝,安裝成功,如下圖
10、編輯 C:\Apache24\conf\httpd.conf,修改默認端口為8080,如下圖
11、在服務列表中查找到Apache2.4,且啟動服務,如下圖
12、打開網址:http://localhost:8080/,成功運行,如下圖
13、因為是執行post請求的壓測,因此需要先准備post數據文件,新建文件:C:\Apache24\bin\post\amiscos.txt,如下圖
14、編輯文件:C:\Apache24\bin\post\amiscos.txt,填充數據,如下圖
15、執行get請求,在 cmd 中進入目錄:C:\Apache24\bin,運行命令:,報錯:,如下圖
建議在使用工具之前,可以參考網址:http://www.shuijingwanwq.com/2017/04/14/1564/ (ab – Apache HTTP server benchmarking tool,翻譯為中文)
ab -c 3 -n 15 ‘http://www.xxx.com/v1/game-team-skills/2721’
This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking ‘http: (be patient)…apr_sockaddr_info_get() for ‘http:: 不知道這 樣的主機。 (731001)
16、執行get請求,在 cmd 中進入目錄:C:\Apache24\bin,運行命令:,去掉了請求網址的單引號,成功運行,如下圖
ab -c 3 -n 15 http://www.xxx.com/v1/game-team-skills/2721
17、執行一個post請求,在 cmd 中進入目錄:C:\Apache24\bin,運行命令:,成功運行,如下圖
ab -c 3 -n 15 -p post/amiscos.txt -T application/x-www-form-urlencoded http://www.xxx.com/v1/amiscos

















