Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure ab to do stress testing for Nginx server

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

Today, I would like to share with you how to configure ab to do stress testing for the Nginx server. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.

Ab is a performance testing tool for apache, and you can install only ab tools.

Ubuntu install ab

Apt-get install apache2-utils

Centos install ab

Yum install httpd-tools

You need to prepare a simple html, a php, and an image file before testing.

Test them separately.

Let's put these three files in the default html directory of the nginx installation directory

When we're ready, we can test it.

Ab-kc 1000-n 1000 http://localhost/ab.html

This instruction uses 1000 concurrency to connect 1000 times. The results are as follows

Root@~# ab-kc 1000-n 1000 http://www.nginx.cn/ab.htmlthis is apachebench, version 2.3 copyright 1996 adam twiss, zeus technology ltd, http://www.zeustech.net/licensed to the apache software foundation Http://www.apache.org/benchmarking www.nginx.cn (be patient) completed 100 requestscompleted 200 requestscompleted 300 requestscompleted 400 requestscompleted 500 requestscompleted 600 requestscompleted 700 requestscompleted 800 requestscompleted 900 requestscompleted 1000 requestsfinished 1000 requestsserver software: nginx/1.2.3server hostname: www.nginx.cnserver port: 80document path: / ab.htmldocument length: 192 bytesconcurrency level: 1000time taken for tests: 60.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 second: 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.martinince.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% 42004999% 49250100% 60443 (longest request)

You can use the same instructions for php files and picture files, but I won't post them.

Ab-kc 500-n 5000 http://localhost/ab.phpab-kc 5000 http://localhost/ab.gif

The output can be understood literally.

Here are two more important indicators.

such as

Requests per second: 16.54 [# / sec] (mean) time per request: 60443.585 [ms] (mean) requests per second: 16.54 [# / sec] (mean)

Indicates that the currently tested server can handle 16.54 static html request transactions per second, followed by an average mean. This value represents the overall performance of the current machine, and the higher the value, the better.

Time per request: 60443.585 [ms] (mean)

The delay time of a single concurrency, and the following mean represents the average.

The average time it takes to complete a request separately from the current concurrency.

By the way, tell the difference between the two time per request.

Time per request: 60443.585 [ms] (mean) time per request: 60.444 [ms] (mean, across all concurrent requests)

The previous one measures the delay of a single request. Cpu takes turns to execute requests in different time slots. In the case of multiple concurrency, it takes such a long time for a concurrent request to get the next time slice.

Calculation method time per request: 60.444 [ms] (mean, across all concurrent requests) * concurrency

The popular point is that when-n 1000 requests are completed with the concurrency of-c 10, an additional request is added to complete the average time required to complete the request.

The latter measure of performance reflects the average time it takes to complete a request and increases the time it takes to complete a request in the current concurrency situation.

Calculation method time taken for tests: 60.444 seconds/complete requests: 1000

In popular terms, it takes longer to complete-n 1001 requests than to complete-n 1000 requests with the concurrency of-c 10.

You can properly adjust the size of-c and-n to test server performance, with the help of htop instructions to visually view the load of the machine.

My machine is an ultra-micro host of Shanda Cloud. The usual load cpu is 1.7%. The result of the command is screenshot.

The pressurized load is 100%, and the load has basically come up. Screenshot of the result of htop command

It seems that I need to optimize it, or change the machine.

Detailed explanation of the parameters of ab

For ordinary testing, you can complete the task by using the-c-n parameter.

Format:. / ab [options] [http://]hostname[:port]/path

Parameters:

The total number of requests tested. By default, only one request is executed

-c the number of concurrent requests at a time. The default is one at a time.

-h add request headers, for example, 'accept-encoding: gzip',' is requested as gzip.

The maximum number of seconds performed by the-t test. Its internal implied value is-n 50000. It can limit the testing of the server to a fixed total time. By default, there is no time limit.

-p contains files that require post data.

The content-type header information used by the t post data.

-v sets the detail level of the display information-4 or greater displays header information, 3 or greater displays response codes (404200, etc.), and 2 or greater displays warnings and other information. -v displays the version number and exits.

-w outputs the results in the format of html table. By default, it is a table with two columns wide on a white background.

-I execute the head request instead of the get.

-c-c cookie-name=value appends a cookie: line to the request. Its typical form is a parameter pair of name=value. This parameter can be repeated.

These are all the contents of the article "how to configure ab to do stress testing for Nginx servers". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report