The tool is Apache-brought and can be used to test how large a site's concurrency is and when a page is accessed.
Basic usage:
1. Go to cmd and go to Apache's Bin directory.
2, the number of times to execute the command ab.exe-n access –c How many people access (concurrent volume) access to the address such as: Ab.exe–n 1000–c http://localhost/index.php;
If you enter the following command Ab.exe-n 10000-c http://localhost/test/index.php,
The content of index.php is
<? PHP for ($i= 0; $i<100; $i+ +) {echo$i. ' | ' ;}
The command means that 100 people access the address 1W times. The following results are present.
[Plain]View Plain Copy
- Server software:apache/2.4.4 #apache版本号
- Server Hostname:localhost
- Server port:80
- Document Path:/test/index.php
- Document Length:5 bytes
- concurrencylevel:100
- Time taken fortests:54.111 seconds #访问的总时间 (sec)
- completerequests:10000 #访问的总次数
- Failed requests:0
- Write errors:0
- totaltransferred:2060000 bytes
- htmltransferred:50000 bytes
- Requests persecond:184.80 [#/sec] (mean) #每秒访问多少次
- Time perrequest:541.111 [MS] (mean) #这么多人 (100) visited once
- Time perrequest:5.411 [MS] (mean, acrossall concurrent requests) #一个人访问一次花费的时间
- Transfer rate:37.18 [Kbytes/sec] Received
In addition, if we increase the number of concurrent numbers to 500, that is, the command is adjusted to Ab.exe-n 10000-c http://localhost/test/index.php it will appear the following results.
[Plain]View Plain Copy
- Apr_socket_connect (): Unable to connect because the target computer was actively refused. (730061)
- Total of 902 requestscompleted
The reason is because Apache defaults to 150 of the maximum concurrent accesses under Windows. We can set the httpd-mpm.conf file under Conf\extra to modify its maximum number of concurrency. Before we make a change, we need to explain what MPM is.
MPM is a multi-channel processing module, that is, how Apache uses the way to handle concurrency, there are three main ways
1. Perfork preprocessing process mode (service with process)
2. Worker mode (thread service under process)
3, Winnt This is generally used under the WinDOS. (for Windows)
Let's finish this and we can fix the configuration file. The steps are as follows:
1. Open the httpd.conf configuration file and open the following configuration
# server-poolmanagement (MPM specific)
Include conf/extra/httpd-mpm.conf
2, determine the current Apache is MPM mode, cmd down into the Apache bin directory input Command httpd.exe–l
The following results can be found to know what mode it is using
[Plain]View Plain Copy
- Compiledin Modules:
- Core.c
- Mod_win32.c
- Mpm_winnt.c This is for Winnt mode
- Http_core.c
- Mod_so.c
3, modify the httpd-mpm.conf file, because from the above can be seen, my Apache is Winnt mode, so in the file to find the corresponding Winnt_module module, modify the parameters, originally 150, we changed it to 1000
[Plain]View Plain Copy
- <IfModulempm_winnt_module>
- Threadsperchild 1000
- Maxconnectionsperchild 0
- </IfModule>
4. Restart the server
After the modification we rerun the above command ab.exe-n 10000-c http://localhost/test/index.php
It will run successfully, with a similar effect to ab.exe-n10000-c http://localhost/test/index.php.
Similarly, if it is a different mode, then modify the corresponding place in the httpd-mpm.conf. As follows
[Plain]View Plain Copy
- <ifmodule mpm_prefork_module>
- Startservers 5 #开始启动的进程
- Minspareservers 5 #最小准备进程
- Maxspareservers #最大空闲进程
- Maxrequestworkers #最大并发数
- Maxconnectionsperchild 0
- </IfModule>
http://blog.csdn.net/zhangzmb/article/details/51884011
PHP's Stress test tool Ab.exe and MPM introduced to increase the number of concurrent