Today introduces a highly efficient performance testing tool wrk. wrk of use and apache bench These tools are also broadly similar, by way of the command line can be initiated. But wrk more efficient than apache bench, because it supports multi-threaded, multi-core CPU capability easier to play, and even pressure over CPU. wrk also supports Lua script to provide more customization parameters, parameter encryption and other needs, a higher degree of flexibility.
installation
wrk supports most UNIX systems, do not support windows system. Installation process is relatively simple, cloned from github project to local, then you can make, this is not detailed in the project path, specifically to see the github documentation.
Basics
Expressed above command line to initiate a request for a local 80 index.html file port pressure measurement time for 30 seconds, 12 concurrent threads, holding 400 HTTP connection requests.
Output:
Posted about 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.
Post request
wrk not only to initiate Get requests, but also through Lua scripts initiate Post request. Such as writing post.lua script:
wrk.method = "POST"
wrk.headers["Content-Type"] = "application/x-www-form-urlencoded"
wrk.body = "youbody&youset"
Define headers and body Post requests in the script. Plus -script specify the script execution wrk request:
So, it can easily achieve pressure measurement Post request.
Follow-up
wrk efficient performance as a test tool can be used as a common means of measuring treatment initiation request url. This article describes the preliminary reference Lua script execution Post request, Lua script can actually realizing a more comprehensive test requirements, next time we'll look at how detailed Lua script wings to wrk.