In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to use wrk, an efficient performance testing tool. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Wrk is used in much the same way as tools such as apache bench, which can be initiated from the command line. But wrk is more efficient than apache bench because it supports multithreading, makes it easier to harness the power of multicore CPU, and even fills up CPU. Wrk also supports Lua scripts to provide more parameter customization, parameter encryption and other requirements for higher flexibility.
Installation
Wrk supports most UNIX systems, not windows systems. The installation process is relatively simple, from the github clone project to the local, and then under the project path make, here do not elaborate, you can see the github documentation.
Basic use of wrk-T12-C400-d30s http://127.0.0.1:80/index.html
The above command line indicates that the request is initiated for the local port 80 index.html file, and the stress test lasts for 30 seconds, and 12 threads are sent simultaneously, keeping 400 HTTP connection requests.
Output result:
Running 30s test @ http://127.0.0.1:80/index.html 12 threads and 400connections Thread Stats Avg Stdev Max + /-Stdev Latency 90.43ms 201.95ms 1.99s 88.34% Req/Sec 1.79k 1.80k 21.57k 89.17% 577891 requests in 30.09s, 188.46MB read Socket errors: connect 0, read 0, write 0 Timeout 37 Non-2xx or 3xx responses: 577891Requests/sec: 19202.50Transfer/sec: 6.26MB
The results show the average request delay Latency, the average number of requests per thread per second Req/Sec, the total number of requests per second Requests/sec and the throughput Transfer/sec per second. These data can reflect the approximate response of the stress test server, in order to make a preliminary judgment on the performance of the server.
Post the requested command parameters:
-c,-- connections: total number of HTTP connections to keep open with each thread handling N = connections/threads-d,-- duration: duration of the test, e.g.2s, 2m, 2h-t,-- threads: total number of threads to use-s,-- script: LuaJIT script, see SCRIPTING-H,-- header: HTTP header to add to request, e.g. User-Agent: wrk-- latency: print detailed latency statistics-- timeout: record a timeout if a response is not received within this amount of time.
About long connections and short connections: apache bench defaults to short connections and wrk defaults to long connections. Wrk to test short connections, add-H "Connection:Close" to close persistent connections.
Post request
Wrk can initiate not only Get requests, but also Post requests through Lua scripts. Such as writing post.lua scripts:
Wrk.method = "POST" wrk.headers ["Content-Type"] = "application/x-www-form-urlencoded" wrk.body = "youbody&youset"
The headers and body for Post requests are defined in the script. Execute the wrk request with-script to specify the script:
Wrk-T4-c2000-d60s-T5s-- script=post.lua-- latency http://127.0.0.1:80/user/login
In this way, the stress test of the Post request can be easily realized.
This is the end of this article on "how to use wrk, an efficient performance testing tool". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.