Use AB for page stress testing
AB is a good stress testing tool that comes with Apache. After installing Apache, you can find AB under bin.
We can simulate 100 concurrent users and send 1000 requests to a page.
# AB-C 100-N 1000 http: // 192.168.0.2/phpMyAdmin requests totaled 1000 times, with each concurrency of 100
# First, Apache version information This is ApacheBench, Version 2.3 <$ revision: 1554214 $> copyright 1996 Adam Twiss, Zeus Technology Ltd, licensed to the Apache Software Foundation, http://www.apache.org/benchmarking 192.168.0.2 (Be patient) server software: Apache/2.4.9 // version number Server Hostname: 192.168.0.2 // request host server port: 80 // access port document path: /phpMyAdmin // The path where the website is stored. document length: 208 bytes // The page length concurrency level: 100 // The concurrency is 100 time taken for tests: 0.543 seconds // time used complete requests: 1000 // Total number of requests failed requests: 0 // failure request Non-2xx responses: 1000 total transferred: 396000 bytes // total number of transmitted bytes, HTML transferred: 208000 bytes // Number of HTML bytes including HTTP header information. The actual number of bytes transmitted on the page requests per second: 1842.10 [#/sec] (mean) // The number of requests per second, which is a very important parameter value for server throughput time per request: 54.286 [MS] (mean) // average user request wait time per request: 0.543 [MS] (mean, messaging SS all concurrent requests) // average server processing time, that is, the reciprocal transfer rate of server throughput: 712.37 [Kbytes/sec] encoded ed // The length of data obtained per second connection times (MS) min mean [+/-SD] median maxconnect: 4 18 11.4 13 68 processing: 3 35 73.8 14 449 waiting: 0 31 73.9 11 446 Total: 15 53 77.0 27 466 percentage of the requests served within a certain time (MS) 50% 27 // 50% requests return 66% 40 75% 45 80% 90% 80 95% 183 98% 357 99% 463 100% 466 (longest request) within 27 Ms)
Here I have configured AN HTTPD + PHP + MySQL environment, installed a phpMyAdmin, and then tested the web page for stress testing. If you want to test it, you need to start testing from the small concurrency, I just had nothing to do, and made a total of 5000 and a concurrency of 500, the result was a tragedy, the server was stuck directly, the Web page could not be refreshed, and I was forced to shut down. The root cause of this situation is that the server configuration cannot respond to a large number of concurrent requests in a timely manner. If many people access this website, it will be very slow to open, this affects the customer's senses.
650) This. width = 650; "Title =" vvv ~ Unzip unzip wg3165@rmrayoi182dl.jpg "src =" http://s3.51cto.com/wyfs02/M02/47/80/wKioL1P7SYGS5cK_AADItJGGvZ0382.jpg "alt =" wkiol1p7sygs5ck_aaditjggvz0382.jpg "/>
650) This. width = 650; "Title =" m6fx51 ~ Certificate (cdb8yt(evhxyhx.jpg "src =" http://s3.51cto.com/wyfs02/M00/47/80/wKioL1P7SZ6Qw7mIAABZXUN7Mvg349.jpg "alt =" wkiol1p7sz6qw7miaabzxun7mvg349.jpg "/>
650) This. width = 650; "Title =" 5) MPU) IA} C ~ D5wx000000008djpolicyt.jpg "src =" http://s3.51cto.com/wyfs02/M01/47/7F/wKiom1P7SKGj_cr2AACr2sf2iE4605.jpg "alt =" wkiom1p7skgj_cr2aacr2sf2ie4605.jpg "/>
PHP accelerator
To increase the server traffic, we can configure the PHP accelerator xcache and use the cache to increase the page access speed.
Xcache is an open-source opcode and VAR cache, which can accelerate PHP because xcache caches PHP compilation results that the user has requested, save the PHP compilation cache in the server's memory so that you can directly read the results from the xcache cache when requesting the same PHP resolution again. Avoid excessive load caused by PHP re-compilation on the server.
Compile xcache
During compilation and installation, xcache is used as a PHP module. during compilation, you must specify the PHP config path.
#/Usr/local/PHP/bin/phpize before compilation, use this command to generate the configure file, because the extracted file does not contain the configure file. Therefore, use this command to generate the configure file. Compile again
650) This. width = 650; "Title =" wn(w2'q47bne1p(dk(8b}nd.jpg "src =" http://s3.51cto.com/wyfs02/M01/47/7F/wKiom1P7TGXzBjkcAADh10nxpp0282.jpg "alt =" wkiom1p7tgxzbjkcaadh10nxpp0282.jpg "/>
Let's take a look at the phpize help documentation.
#man -M /usr/local/php/php/man/ phpize
Because the man manual was not added during the last PHP compilation, man-m must be used here, prompting you to prepare a PHP extension for compilation.
650) This. width = 650; "Title =" n[in58sqqi_iftr?mburh=9.jpg "src =" http://s3.51cto.com/wyfs02/M02/47/7F/wKiom1P7TMjxhWQDAAEVQdOwuh0036.jpg "alt =" wkiom1p7tmjxhwqdaaevqdowuh0036.jpg "/>
#tar xf xcache-3.1.0.tar.gz#cd xcache-3.1.0#/usr/local/php/bin/phpize
650) This. width = 650; "Title =" @ 0 {PSMH (pnevgxu42g ~ Re1k.jpg "src =" http://s3.51cto.com/wyfs02/M02/47/80/wKioL1P7TmOA7DfZAAGMnetzZpI196.jpg "alt =" wkiol1p7tmoa7dfzaagmnetzzpi196.jpg "/>
#./configure --enable-xcache --with-phpconfig=/usr/local/php/bin/php-config#make && make install
Create a directory and copy xcache. ini to the new directory.
#mkdir /etc/php.d#cp xcache.ini /etc/php.d
Next, edit/etc/PHP. d/xcache. ini, find the line starting with extension, and change it to the following line:
Extension =/usr/local/PHP/lib/PHP/extensions/no-debug-zts-20100525/xcache. So
650) This. width = 650; "Title =" (41_ux1ijmn%b9r76g%%ptm.jpg "src =" http://s3.51cto.com/wyfs02/M02/47/7F/wKiom1P7TjqzmxD3AABmk3OD89Y304.jpg "alt =" wkiom1p7tjqzmxd3aabmk3od89y304.jpg "/>
Check whether xcache exists on the PHP display page.
650) This. width = 650; "Title =" too many characters please r%5%%bwoid%%verver(ms.jpg "src =" http://s3.51cto.com/wyfs02/M00/47/80/wKioL1P7T5KSDwvtAAHEqmDszc4229.jpg "alt =" wkiol1p7t5ksdwvtaaheqmdszc4229.jpg "/>
This indicates that xcache has been added to PhP.
Now let's test the access speed.
650) This. width = 650; "Title =" m1%5b%%8%'2_meyk5kn'lj9.jpg "src =" http://s3.51cto.com/wyfs02/M00/47/7F/wKiom1P7TtDQDeVMAAEejTL36s0177.jpg "alt =" wkiom1p7ttdqdevmaaeejtl36s0177.jpg "/>
Looking at this result, we can compare it with the above test to clearly experience the importance of the PHP accelerator.
Server Status
The mod_status module allows the Administrator to view the execution status of the server. It displays the statistics of the current server on an HTML page. The data usually includes but is not limited:
1. Number of worker processes in the working state;
2. Number of idle worker Processes;
3. The status of each worker, including the number of requests that the worker has responded to and the number of bytes of the content sent by the worker;
4. Total number of bytes sent by the current server;
5. The current duration of the server since it was last started or restarted;
6. Average number of requests per second, average number of bytes sent per second, and average number of bytes requested by each request;
To enable the status page, you only need to add the following content to the main configuration file:
<Location/status>
Sethandler server-status
Require all granted
</Location>
It should be noted that the status information here should not be randomly accessed by everyone. Therefore, it should be restricted to allow only clients with specific addresses to view the status information. For example, you can use require IP 192.168.0.3/24 to restrict only hosts with specified network segments to view this page.
650) This. width = 650; "Title =" 0t4jy'05e(dd%xy2%t6qi%k.jpg "src =" http://s3.51cto.com/wyfs02/M01/47/81/wKioL1P7UZzSreKFAALgBmR8x04605.jpg "alt =" wkiol1p7uzzsrekfaalgbmr8x04605.jpg "/>
This article from the fish blog, please be sure to keep this source http://kyfish.blog.51cto.com/1570421/1544959
AB stress testing and xcache