1、基于AB测试工具进行高并发情形下的模拟测试,打开:http://httpd.apache.org/docs/current/platform/windows.html#down,如图1

图1

2、选择ApacheHaus,下载,2.4版本的x64的二进制文件,如图2

图2

3、下载文件名为:httpd-2.4.25-x64-vc14-r1.zip,如图3

图3

4、解压缩之后,将Apache24复制至C:\Apache24,如图4

图4

5、在 cmd 中进入目录:C:\Apache24\bin,运行命令:httpd -k install,将Apache安装为一个服务,报错:无法启动此程序,因为丢失 VCRUNTIME140.dll。尝试重新安装该程序以解决此问题。如图5

图5

6、安装Visual C++ 2015、Visual C++ 2015 x64,如图6

图6

7、在 cmd 中进入目录:C:\Apache24\bin,运行命令:httpd -k install,将Apache安装为一个服务,报错:。如图7

Installing the ‘Apache2.4’ service
(OS 5)拒绝访问。 : AH00369: Failed to open the Windows service manager, perhaps you forgot to log in as Adminstrator?

图7

8、右键 Windows 图标,打开命令提示符(管理员),如图8

图8

9、再次安装,安装成功,如图9

图9

10、编辑 C:\Apache24\conf\httpd.conf,修改默认端口为8080,如图10

图10

11、在服务列表中查找到Apache2.4,且启动服务,如图11

图11

12、打开网址:http://localhost:8080/,成功运行,如图12

图12

13、因为是执行post请求的压测,因此需要先准备post数据文件,新建文件:C:\Apache24\bin\post\amiscos.txt,如图13

图13

14、编辑文件:C:\Apache24\bin\post\amiscos.txt,填充数据,如图14

图14

15、执行get请求,在 cmd 中进入目录:C:\Apache24\bin,运行命令:,报错:,如图15

建议在使用工具之前,可以参考网址: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)

图15

16、执行get请求,在 cmd 中进入目录:C:\Apache24\bin,运行命令:,去掉了请求网址的单引号,成功运行,如图16

ab -c 3 -n 15 http://www.xxx.com/v1/game-team-skills/2721

图16

17、执行一个post请求,在 cmd 中进入目录:C:\Apache24\bin,运行命令:,成功运行,如图17
ab -c 3 -n 15 -p post/amiscos.txt -T application/x-www-form-urlencoded http://www.xxx.com/v1/amiscos

图17

 

永夜

View Comments