High-Performance PHP learning benchmark testing technology

Source: Internet
Author: User
High-Performance PHP learning benchmark testing technology I. benchmarking tools

The benchmark testing tool provides statistics on Web server responses when a variety of simulated user requests occur. They allow us to simulate any number of users who request a specific Web document on the Web server. More importantly, it allows us to simulate any number of users to access documents (concurrent requests) on the Web server at the same time ).

For example, the information provided by each tool is related to the following:
1. total time spent in responding to a request
2. total response size from the server
3. total number of requests that the Web server can process per second

II. Apache Benchmark
Here I will introduce Apache Benchmark (AB/ab2) tool.
This is one of the most famous benchmark testing tools. it is part of the default Apache installation and can conduct load testing on the Web server by simulating any number of requests to a specific URL. The AB tool provides the following information:
1. total data size transmitted (in bytes)
2. total number of requests that the Web server can support per second under simulated traffic
3. the maximum time taken to complete a request (in milliseconds)
4. the minimum time required to complete a request (in milliseconds)
Note: The AB Command is run in the ubuntu operating system, while the opensuse command is used by the Author. the command used in this system is ab2. therefore, the ab2 command is used during operations, for convenience, AB commands are always written.


The AB tool can also run many different load simulations, such:
1. simulate requests to Web documents
2. requests within a specified time period
3. requests for opening Keep-Alive
Most importantly, Apache Benchmark is independent of the Apache Web server, so that you can run the tool while running AB.
The Web server on the computer is inactive.


3. install Apache Benchmark
In linux/Unix systems, you only need to install apache and then use the AB Command.

In windows, you can open http://httpd.apache.org /. After loading this page, click the "Download from a mirror" (Download from image) link on the left side of the page to find the appropriate Download package for your system, that is, Windows 32 Binary version, and then Download it.
After the package is downloaded, you can run the installation wizard to install the software anywhere in the system. I installed Apache in the default location C: \ Program Files \ Apache Software Foundation, but it can also be installed anywhere in the system. The location selected here is the location pointed to by the APACHE_HOME reference.
Now open \ Apache2.2 \ bin. You can see the collection of files and directories shown in.

4. use the AB Command
Now, let's use the AB tool. (The benchmark test uses www.example.com as an example)
The composition of all AB commands follows this structure:
AB [options] [full path to web document]
Example:
Http://www.example.com/AB-n 1/
N indicates the number of requests executed on the specified URL. In this example, AB requests the Web document only once, but the value of n can be any number smaller than 50000. By default, n is set to 1.
The next part of the command is the URL part. For the command just executed, the URL is http://www.example.com /. If you choose to test a document in this domain, such as test. php (does not exist), the URL is: http://www.example.com/test.php
The result of executing the preceding command is shown in:



URLhttp: // The AB response of www.example.com

Data is divided into four parts
1. server information
Contains software running on the Web server, host name, and server listening port number.

2. Script information
Contains information about running simulated Web documents. Document Path contains the requested Document, while Document Length contains the total number of bytes of all HTML, images, CSS, JS, and any content in the response.

3. connection information
The entity that contains the information. It answered, for example, "How long does it take to receive a request response ?" , "How much data is returned ?" The most important thing is that it answers "how many users can the Web server support when processing documents ?".
The following table provides a complete list and description of the data.





AB response description

4. connection indicator category
The last part contains a table, including the Connect, Processing, Waiting, and Total fields. These fields tell us the time required for the request in each process status. We are most interested in the Total field and its maximum and minimum columns.



AB option flag


The following are some tests based on the above labels.
1. Concurrent testing
Simulate a concurrent Test and perform 10 concurrent requests on the Web server until 100 request locations are reached. A warning when c is used is to make the used value less than or equal to the total number of requests to be processed n.
Example: AB-n 100-c 10 http://www.example.com
The response of the AB Command is as follows:


Concurrent simulation result of www.example.com



By simulating concurrent requests, we can see the Request per second field, and note that the Web server can support requests (users) per second ). After analyzing the Total min and max columns of Connection Metrics, we noticed that the fastest response was 371 milliseconds under the specified traffic load of 10 concurrent requests, and the slowest request took 575 milliseconds.
However, we know that the traffic will not only last for 1, 2, or 3 seconds. the high traffic may last for several minutes, hours, or even days. Let's run a simulation to test it.

2. time test
The t mark can check the Web server execution at any time.
Below we use the following command to simulate 10 users simultaneously accessing the website in 20 seconds:
AB-c 10-t 20 http://www.example.com/
Note: this command does not contain the n mark, but by default it contains the mark and AB sets its value to 50000 when the t option is used. In some cases, when the t option is used, the maximum number of requests may reach 50000, and the simulation ends.

The response of the AB Command is as follows:




Benchmark test results for www.example.com/( 10 concurrent users within 20 seconds)


The simulation results indicate that the performance will decrease when 10 concurrent users request Web documents within 20 seconds. It took 464 milliseconds to quickly meet the request, and 1890 milliseconds to get the slowest request.


5. AB traps
There are several warnings when using AB.
1. check the command executed above and you will notice a backslash at the end of the domain name. This backslash is required if you do not request specific documents in the domain.
2. AB may also be blocked by some Web servers because of the user proxy value it passes to the Web server. in such cases, AB may not receive any data. To solve this problem, use one of the available options to mark-H to provide custom browser header information for your request.

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.