PHP program acceleration exploration [3] - server load test

xiaoxiao2021-03-06  96

<1> test

◆ Server load test

The server load is too large and the effect is also very common, and we need to test this. Here I am using the most commonly used Apache server.

The Apache server comes with a tool called AB (Apachebench), in the bin directory. Using this lightweight tool we can load testing on the server to see how the server is performed under heavy load. ApacheBench can simulate a continuous online request for a particular URL, and can also simulate the same online request, so use ApacheBench to help us simulate the like or on the line during website development, using the simulation Data is used as a basis for adjusting the server settings or programs.

Output on the command line:

./AB -N Number_Of_total_requests / -c number_of_simultaneous_requests / http://your_web_server/your_php_app.php

E.g:

./AB-N 1000 -C 50 http://www.domain.com/myapp.php

AB will simultaneously send 50 concurrent requests to http://www.domain.com/myapp.php, a total of 1000 times.

The test results will be likely to:

Server Software: Apache / 2.0.16Server Hostname: localhostServer Port: 80Document Path: /myapp.phpDocument Length: 1311 bytesConcurrency Level: 50Time taken for tests: 8.794 secondsComplete requests: 1000Failed requests: 0Total transferred: 1754000 bytesHTML transferred: 1311000 bytesRequests per second: 113.71Transfer Rate: 199.45 KB / S ReceivedConnection Times (MS) MIN AVG MAXCONNECT: 0 0 555555Total: 111 427 555

MyApp.php The number of requests can be processed per second is 113.71. Add the number of requests to see if the server can handle greater pressure. You also need to adjust the Apache's MaxClients, Threadsperchild, MaxthReadsperChild, etc., based on the MPM module in your httpd.conf.

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

Remember each parameter and finally select the configuration of optimum efficiency.

It is to point out that in addition to AB, there are many excellent server performance test software. Also, if your server is not Apache, please find your test method.

转载请注明原文地址:https://www.9cbs.com/read-123849.html

New Post(0)