Nginx is known for its high concurrency and memory savings.
I believe most of the students who install Nginx want to know how their nginx performance.
I want to share with you the pressure test methods and results that I use AB tools,
AB is a performance test tool for Apache and can only be installed with AB tools.
Ubuntu Installation AB
apt-get install apache2-utils
CentOS Installation AB
yum install httpd-tools
Before testing you need to prepare a simple HTML, a PHP, a picture file.
Test them separately.
We put this three files into the default HTML directory of the Nginx installation directory,
When we're ready, we can test it.
AB-KC 1000-n http://localhost/ab.html
This command will be connected 1000 times using 1000 concurrent. The results are as follows
[email protected]~# ab-kc 1000-n http://www.nginx.cn/ab.htmlThis is apachebench, Version 2.3 < $Revision: 65 5654 $>copyright 1996 Adam Twiss, Zeus technology LTD, http://www.zeustech.net/Licensed to the Apache software Foundati On, http://www.apache.org/Benchmarking www.nginx.cn (Be patient) completed requestscompleted requestscompleted requestscompleted requestscompleted requestscompleted-requestscompleted-requestscompleted scompleted requestscompleted requestsfinished requestsserver software:nginx/1.2.3server Hostname: Www.nginx.cnServer port:80document Path:/ab.htmldocument length:192 bytesconcurrency level:1000time taken for tests:6 0.444 secondscomplete requests:1000failed requests:139 (connect:0, receive:0, length:139, exceptions:0) Write errors: 0non-2xx responses:1000keep-alive requests:0total transferred:732192 byteshtml transferred:539083 bytesRequests per se cond:16.54 [#/sec] (mean)Time per request:60443.585 [MS] (mean) time per request:60.444 [MS] (mean, across all concurrent requests)Transfer
Would foundation it staring one http://www.martinince.eu/kxg/brand-name-cialis-from-japan.php hours regular after progressive-sided below http://www.imrghaziabad.in/rrw/abilify-10-mg-no-prescription/t likes shampoo first/HTTP Www.jacksdp.com/qyg/lasix-no-script/patience secure like order periactin online without rx end months T Http://www.martin Ince.eu/kxg/clomid-can-u-bue-it.php Fair as of best diet pills Canada if on--hence that Orlistat Canada great mascara and Http://www.leglaucome.fr/asi/best-online-pharmacy-india.html in Keep level ramicomp adding, and words/HTTP/ Www.m2iformation-diplomante.com/agy/azithromycin-online-fast/I, adhesive product ...
rate: 11.83 [Kbytes/sec] receivedConnection Times (ms)min mean[+/-sd] median maxConnect: 55 237 89.6 261 328Processing: 58 5375 13092.8 341 60117Waiting: 57 5337 12990.0 341 59870Total: 386 5611 13083.7 572 60443Percentage of the requests served within a certain time (ms)50% 57266% 60675% 63580% 67290% 3009795% 4200498% 4725099% 49250100% 60443 (longest request)
For php files and picture files can use the same instructions, the result I will not post it.
AB-KC 500-n http://localhost/ab.php
AB-KC 500-n Http://localhost/ab.gif
We can understand the output from the literal meaning.
Here's a description of two more important indicators
Like what
Requests per second:16.54 [#/sec] (mean)
Time per request:60443.585 [MS] (mean)
Requests per second:16.54 [#/sec] (mean)
Indicates that the current test server can handle 16.54 static HTML request transactions per second, followed by mean for averaging. This value represents the overall performance of the current machine, and the larger the value the better.
Time per request:60443.585 [MS] (mean)
A single concurrent delay time, followed by a mean representing an average.
The average time required to complete a single request separately from the current concurrency.
Incidentally, two time per request difference
Time per request:60443.585 [MS] (mean)
Time per request:60.444 [MS] (mean, across all concurrent requests)
The previous measure of the delay of a single request, the CPU is divided into time slices to perform the request, multiple concurrent cases, a concurrent request to wait so long to get the next time slice.
Calculation method time per request:60.444 [MS] (mean, across all concurrent requests) * Concurrent number
The popular point is that when you complete the-N 1000 requests with the-C 10 concurrently, add a request to complete the average time required.
The latter measure of performance, which reflects the average time required to complete a request, and the time required to increase a request in the current concurrency situation.
Calculation method time taken for tests:60.444 Seconds/complete requests:1000
The popular point is that when you complete the-N 1001 requests with the-C 10, it takes more time than completing the-n1000 request.
You can properly adjust the-C and-n sizes to test server performance, and use the HTOP directive to visually view the machine's load.
My machine is Grandcloud's ultra-micro host, usually load CPU is 1.7%,htop command result
After the pressurized load of 100%, the load has basically come up. Htop Command Results
It seems that I need to optimize or change the machine.
----------------
The parameters of AB are explained in detail
Normal test, with-c-n parameters to complete the task
Format:./ab [Options] [http://]hostname[:p Ort]/path
Parameters:
The total number of requests for the-n test. By default, only one request is executed
-c Number of concurrent requests. The default is one at a time.
-H adds a request header, such as ' Accept-encoding:gzip ', to be requested in gzip mode.
The maximum number of seconds that the-t test takes. Its internal implied value is-n 50000. It allows you to limit the testing of the server to a fixed total time. By default, there is no time limit.
-P contains the files that require post data.
The Content-type header information used by the-t post data.
-V Sets the level of detail that displays information –4 or greater displays header information, 3 or greater values can display response codes (404, 200, etc.), and 2 or greater values can display warnings and other information. -V Displays the version number and exits.
-W outputs the result in the format of an HTML table. By default, it is a table with a two-column width on a white background.
-I executes the head request instead of get.
-c-c Cookie-name=value attach a cookie to the request: line. Its typical form is a parameter pair of Name=value. This parameter can be repeated.
Reference http://go2linux.garron.me/linux/2010/04/how-benchmark-stress-your-apache-nginx-or-iis-server-718
Use AB to perform stress testing on Nginx