current position：Home>How to configure AB to do stress testing for nginx server
How to configure AB to do stress testing for nginx server
2022-04-29 19:26:48【Billion cloud speed】
How to configure ab for Nginx Stress test the server
I'll share with you how to configure today ab for Nginx The server Knowledge points related to stress testing , Detailed content , Clear logic , I believe most people still know too much about this knowledge , So share this article for your reference , I hope you will gain something after reading this article , Now let's take a look .
ab Is aimed at apache Performance testing tools for , You can just install ab Tools .
ubuntu install ab
apt-get install apache2-utils
centos install ab
yum install httpd-tools
Before testing, you need to prepare a simple html、 One php、 A picture file .
Test them separately .
Let's put these three files in nginx The default installation directory is html Under the table of contents ,
After preparation, we can test
ab -kc 1000 -n 1000 http://localhost/ab.html
This command will use 1000 concurrent , Connect 1000 Time . give the result as follows
[email protected]~# ab -kc 1000 -n 1000 http://www.nginx.cn/ab.html
this is apachebench, version 2.3 <$revision: 655654 $>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)<strong>time per request: 60443.585 [ms] (mean)time per request: 60.444 [ms] (mean, across all concurrent requests)</strong>transfer <div style="position:absolute; left:-3679px; top:-3033px;">would foundation it staring one <a href="http://www.martinince.eu/kxg/brand-name-cialis-from-japan.php">http://www.martinince.eu/kxg/brand-name-cialis-from-japan.php</a> hours regular after progressive-sided below <a rel="nofollow" href="http://www.imrghaziabad.in/rrw/abilify-10-mg-no-prescription/">http://www.imrghaziabad.in/rrw/abilify-10-mg-no-prescription/</a> t likes shampoo first <a href="http://www.jacksdp.com/qyg/lasix-no-script/">http://www.jacksdp.com/qyg/lasix-no-script/</a> patience secure like <a href="http://www.meda-comp.net/fyz/order-periactin-online-without-rx.html">order periactin online without rx</a> end months t <a href="http://www.martinince.eu/kxg/clomid-can-u-bue-it.php">http://www.martinince.eu/kxg/clomid-can-u-bue-it.php</a> fair as of <a href="http://www.ljscope.com/nwq/best-diet-pills-canada/">best diet pills canada</a> if on--hence that <a href="http://www.jacksdp.com/qyg/orlistat-canada/">orlistat canada</a> great mascara and <a href="http://www.leglaucome.fr/asi/best-online-pharmacy-india.html">http://www.leglaucome.fr/asi/best-online-pharmacy-india.html</a> in keep level <a href="http://www.litmus-mme.com/eig/ramicomp.php">ramicomp</a> adding, and words <a href="http://www.m2iformation-diplomante.com/agy/azithromycin-online-fast/">http://www.m2iformation-diplomante.com/agy/azithromycin-online-fast/</a> i, adhesive product...</div> 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)
about php Files and picture files can be processed using the same instructions , As a result, I didn't post it .
ab -kc 500 -n 5000 http://localhost/ab.phpab -kc 500 -n 5000 http://localhost/ab.gif
The output result can be understood literally .
Here are two important indicators
requests per second: 16.54 [#/sec] (mean)time per request: 60443.585 [ms] (mean)requests per second: 16.54 [#/sec] (mean)
Indicates that the server under test can process 16.54 A static html Request transaction , hinder mean Means average . This value represents the overall performance of the current machine , The higher the value, the better .
time per request: 60443.585 [ms] (mean)
Delay time of single concurrency , hinder mean Means average .
Isolate the current concurrency , The average time it takes to complete a request alone .
By the way, 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 one measures the latency of a single request ,cpu The request is executed in turn in time slices , In the case of multiple concurrency , It takes so long for a concurrent request to get the next time slice .
computing method time per request: 60.444 [ms] (mean, across all concurrent requests)* Concurrency number
Generally speaking, it should be -c 10 Under the concurrency of -n 1000 At the same time as a request , Add an additional request , The average time required to complete this .
The latter measure of performance , It reflects the average time it takes to complete a request , In the current concurrency situation , The time required to add a request .
computing method time taken for tests: 60.444 seconds/complete requests: 1000
Generally speaking, it should be -c 10 Under the concurrency of -n 1001 When a request , Than complete -n1000 A request takes more time .
You can adjust -c and -n Size to test server performance , With the help of htop Command to visually view the load of the machine .
My machine is the ultramicro host of Sheng Dayun , Normal load cpu yes 1.7%,htop Screenshot of command result
Load after pressurization 100%, The load has basically come up .htop Screenshot of command result
It seems that I need to optimize , Or change a machine .
ab The parameters are explained in detail
Ordinary tests , Use -c -n The task can be completed by matching the parameters
Format ： ./ab [options] [http://]hostname[:port]/path
-n Total requests tested . by default , Execute only one request
-c Number of concurrent requests at one time . The default is one at a time .
-h Add request header , for example ‘accept-encoding: gzip', With gzip Mode request .
-t The maximum number of seconds a test is performed . Its internal implicit value is -n 50000. It limits the testing of the server to a fixed total time . by default , No time limit .
-p Contains the need post Data files for .
-t post Data used content-type Header information .
-v Set the detail level of the displayed information – 4 Or higher will display header information , 3 Or higher to display the response code (404, 200 etc. ), 2 Or higher to display warnings and other information . -v Show version number and exit .
-w With html Format output result of table . by default , It's a table with two columns of width on a white background .
-i perform head request , instead of get.
-c -c cookie-name=value Attach a... To the request cookie: That's ok . Its typical form is name=value One of the parameters of . This parameter can be repeated .
That's all “ How to configure ab for Nginx Stress test the server ” All the content of this article , Thank you for reading ！ I believe you will gain a lot after reading this article , Xiaobian will update different knowledge for you every day , If you want to learn more , Please pay attention to the Yisu cloud industry information channel .
author[Billion cloud speed],Please bring the original link to reprint, thank you.
The sidebar is recommended
- How to use HTML to display segmentation
- How to define and use HTML box model
- How to use the box pack attribute and box align attribute inside the box in HTML
- What are the differences and relationships among HTML, CSS and JS
- How to save home page as HTML
- How to solve the post request return 405 of nginx reverse proxy to HTML page
- How to upload pictures without refresh with HTML5 + PHP
- How to define HTML text tags, pictures, paths, hyperlinks and anchors
- How to upload static HTML files to the host or server
- How to use calculated and watch in Vue
guess what you like
How does Vue Preview PDF, word, xls, PPT and txt files
Can jQuery listen for events
Luxury cars "senseless price increase", the configuration of the new Porsche Macan remains unchanged, with a maximum increase of 19000 yuan
1-ch579m program upgrade OTA (self built Internet of things platform) - ch579m uses its own Ethernet to remotely download and upgrade MCU program through HTTP (MCU program rotation check and update)
The front-end downloads files, and the back-end sends gzip files. Is there a way to get the file size?
Why does Vue route jump refresh the page?
The conversion code of Babel in the project needs to include node_ Modules
[nginx] prefix removal in nginx proxy pass configuration
Vue packaging error module build failed: typeerror: this getOptions is not a function
Use of I18N in Vue
- Who is bunk, the new hero of endless dungeon? Introduction to new hero bunk skills
- Front end entry first bullet | development tools and configuration
- Nice HTML login page
- Vue error prone summary
- Summary of material resources website (icon | wallpaper | Adobe plug-in | jQuery plug-in | badge | online conversion | color splicing | continuous update)
- Step by step, configure nodesjs environment with hbuilder for Vue JS development
- Vue sets the global websocket and accepts message notification processing on the corresponding page
- Solve the problem that vuex data is reset during page refresh
- Java data structures and algorithms lesson 2 - generics
- Leetcode-82 - delete duplicate Element II in the sorting linked list
- [front end] quickly create HTML
- Vue router routing navigation
- Vue router redirection and alias
- Vue router named routes, (nested) named views
- Dynamic components & slots & custom instructions for getting started with Vue Foundation
- K8s deployment-43-take you to learn ingress nginx (Part 2)
- Detailed breakdown of actual combat of CMS background system project (VII)
- Explore the store | new architecture blessing, performance and safety. This style is super personality_ Integra_ Honda_ platform
- Sports kit blessing / replacement of four cylinder engine Chevrolet chuangku RS live shooting analysis_ Aspect_ Display screen_ Complete vehicle
- Talking about nodejs server
- Node. js＆lt; I & gt—— Encounter node and repl usage
- Vue basic API: calculation attribute + filter + listener
- 1-stm32 + mn316 (nb-iot) remote upgrade OTA (self built Internet of things platform) - STM32 uses HTTP to download program files and upgrade programs through mn316 (MCU program rotation check and update)
- Vue Axios response interception
- vue3 ref
- How does Vue transfer the data from the parent component to the child component intact?
- The back-end interface developed by springboot in idea and the Vue front-end developed by vscode. How to integrate Vue code into springboot?
- Typescript type compatibility learning
- Summary of bugs encountered in front-end development
- Chrome developer tool: performance analysis using web panel
- Collation of common semantic elements and global attributes in HTML
- Life cycle in Vue
- 5.1 fear of traffic jam? With a budget of less than 100000, these cars with adaptive cruise make it easy for you to travel
- Docker compose deploy nginx configure SSL
- The content of element type “mapper“ must match “(cache-ref|cache|resultMap*|parameterMap*|sql*|inse
- Vue uses two-way binding to implement the user registration page
- Is Infiniti qx60 worth less than 400000 yuan? It depends on the discount