PHP's Stress test tool Ab.exe and MPM introduced to increase the number of concurrent

Source: Internet
Author: User
Tags vars server port

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
  1. Server software:apache/2.4.4 #apache版本号
  2. Server Hostname:localhost
  3. Server port:80
  4. Document Path:/test/index.php
  5. Document Length:5 bytes
  6. concurrencylevel:100
  7. Time taken fortests:54.111 seconds #访问的总时间 (sec)
  8. completerequests:10000 #访问的总次数
  9. Failed requests:0
  10. Write errors:0
  11. totaltransferred:2060000 bytes
  12. htmltransferred:50000 bytes
  13. Requests persecond:184.80 [#/sec] (mean) #每秒访问多少次
  14. Time perrequest:541.111 [MS] (mean) #这么多人 (100) visited once
  15. Time perrequest:5.411 [MS] (mean, acrossall concurrent requests) #一个人访问一次花费的时间
  16. 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
    1. Apr_socket_connect (): Unable to connect because the target computer was actively refused. (730061)
    2. 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
    1. Compiledin Modules:
    2. Core.c
    3. Mod_win32.c
    4. Mpm_winnt.c This is for Winnt mode
    5. Http_core.c
    6. 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
    1. <IfModulempm_winnt_module>
    2. Threadsperchild 1000
    3. Maxconnectionsperchild 0
    4. </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
    1. <ifmodule mpm_prefork_module>
    2. Startservers 5 #开始启动的进程
    3. Minspareservers 5 #最小准备进程
    4. Maxspareservers #最大空闲进程
    5. Maxrequestworkers #最大并发数
    6. Maxconnectionsperchild 0
    7. </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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.