PHP program to accelerate the discovery of server load test

Source: Internet
Author: User
Tags command line server port

The server load is too large to affect program efficiency is also very common, we need to test this. Here I take the current most common Apache server as an example.

The Apache server comes with a tool called AB (Apachebench), which is in the bin directory. Using this lightweight tool we can load test the server to see how the server behaves under heavy load. Apachebench can simulate a continuous online request for a particular URL while also emulating the same online request at the same point in time, so using apachebench can help us simulate actual line possible situations during site development, Use the simulated data as the basis for adjusting the server settings or programs.

Output at the command line:

./ab -n number_of_total_requests\
-c number_of_simultaneous_requests\
http://your_web_server/your_php_app.php

For example:

./ab-n 1000-c http://www.domain.com/myapp.php

AB will issue 50 concurrent requests to the http://www.domain.com/myapp.php at the same time, a total of 1000 times.

The test results will probably be like this:

Server Software: Apache/2.0.16
Server Hostname: localhost
Server Port: 80
Document Path: /myapp.php
Document Length: 1311 bytes
Concurrency Level: 50
Time taken for tests: 8.794 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 1754000 bytes
HTML transferred: 1311000 bytes
Requests per second: 113.71
Transfer rate: 199.45 kb/s received
Connection Times (ms)
min avg max
Connect: 0 0 5
Processing: 111 427 550
Total: 111 427 555

Myapp.php the number of requests that can be processed per second is 113.71. Increase the number of requests to see if the server can handle greater pressure. You also need to adjust the maxclients,threadsperchild,maxthreadsperchild parameters of Apache based on your httpd.conf MPM module selection.

If you want more detailed information, go to www.apache.org for more in-depth documentation, including modules and third-party productivity tools. After modifying the httpd.conf, restart the Apache server and then use the AB test. You will see an increase or decrease in the number of requests per second.

Make a note of each parameter and finally choose the one that is optimal for efficiency.

To point out that, in addition to AB, there are many excellent server performance testing software. Also, if your server is not Apache, look for a test method yourself.

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.