没有不值得去解决的问题,也没有不值得去学习的技术!

How to Install and Use the ab Tool on Windows 10 x64

执行一个post请求,在 cmd 中进入目录:C:\Apache24\bin,运行命令:,成功运行

1. To simulate high-concurrency scenarios using the AB testing tool, open: http://httpd.apache.org/docs/current/platform/windows.html#down, as shown in Figure 1.

AB testing tool official website
Figure 1

2. Select ApacheHaus and download the x64 binary file for version 2.4, as shown in Figure 2.

Select ApacheHaus and download the x64 binary file for version 2.4
Figure 2

3. The downloaded file is named: httpd-2.4.25-x64-vc14-r1.zip, as shown in Figure 3.

The downloaded file is named: httpd-2.4.25-x64-vc14-r1.zip
Figure 3

4. After decompression, copy Apache24 to C:\Apache24, as shown in Figure 4.

After decompression, copy Apache24 to C:\Apache24
Figure 4

5. In cmd, navigate to the directory: C:\Apache24\bin and run the command: httpd -k install to install Apache as a service. An error occurs: “The program can’t start because VCRUNTIME140.dll is missing. Try reinstalling the program to fix this problem.” As shown in Figure 5.

In cmd, navigate to the directory: C:\Apache24\bin and run the command: httpd -k install to install Apache as a service. An error occurs: "The program can't start because VCRUNTIME140.dll is missing. Try reinstalling the program to fix this problem."
Figure 5

6. Install Visual C++ 2015 and Visual C++ 2015 x64, as shown in Figure 6.

Install Visual C++ 2015 and Visual C++ 2015 x64
Figure 6

7. In cmd, navigate to the directory: C:\Apache24\bin and run the command: httpd -k install to install Apache as a service. An error occurs: . As shown in Figure 7.

Installing the ‘Apache2.4’ service
(OS 5)Access is denied. : AH00369: Failed to open the Windows service manager, perhaps you forgot to log in as Adminstrator?

In cmd, navigate to the directory: C:\Apache24\bin and run the command: httpd -k install to install Apache as a service. An error occurs: .
Figure 7

8. Right-click the Windows icon and open Command Prompt (Admin), as shown in Figure 8.

Right-click the Windows icon and open Command Prompt (Admin)
Figure 8

9. Install again; the installation succeeds, as shown in Figure 9.

Install again; the installation succeeds
Figure 9

10. Edit C:\Apache24\conf\httpd.conf and change the default port to 8080, as shown in Figure 10.

Edit C:\Apache24\conf\httpd.conf and change the default port to 8080
Figure 10

11. Find Apache2.4 in the services list and start the service, as shown in Figure 11.

Find Apache2.4 in the services list and start the service
Figure 11

12. Open the URL: http://localhost:8080/. It runs successfully, as shown in Figure 12.

Open the URL: http://localhost:8080/. It runs successfully
Figure 12

13. Because we are running a stress test for a POST request, we need to prepare the POST data file first. Create a new file: C:\Apache24\bin\post\amiscos.txt, as shown in Figure 13.

Because we are running a stress test for a POST request, we need to prepare the POST data file first. Create a new file: C:\Apache24\bin\post\amiscos.txt
Figure 13

14. Edit the file: C:\Apache24\bin\post\amiscos.txt and fill in the data, as shown in Figure 14.

Edit the file: C:\Apache24\bin\post\amiscos.txt and fill in the data
Figure 14

15. To execute a GET request, in cmd, navigate to the directory: C:\Apache24\bin and run the command: . An error occurs: , as shown in Figure 15.

Before using the tool, you can refer to the URL: https://www.shuijingwanwq.com/2017/04/14/1564/ (ab – Apache HTTP server benchmarking tool, translated into Chinese)

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:: No such host is known. (731001)

To execute a GET request, in cmd, navigate to the directory: C:\Apache24\bin and run the command: . An error occurs:
Figure 15

16. To execute a GET request, in cmd, navigate to the directory: C:\Apache24\bin and run the command: . The single quotes around the request URL were removed, and it ran successfully, as shown in Figure 16.

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

To execute a GET request, in cmd, navigate to the directory: C:\Apache24\bin and run the command: . The single quotes around the request URL were removed, and it ran successfully
Figure 16

17. To execute a POST request, in cmd, navigate to the directory: C:\Apache24\bin and run the command: . It runs successfully, as shown in Figure 17.
ab -c 3 -n 15 -p post/amiscos.txt -T application/x-www-form-urlencoded http://www.xxx.com/v1/amiscos

To execute a POST request, in cmd, navigate to the directory: C:\Apache24\bin and run the command: . It runs successfully
Figure 17

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系