Efficient performance testing tool -wrk

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

wrk -t12 -c400 -d30s http://127.0.0.1:80/index.html

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:

Running 30s test @ http://127.0.0.1:80/index.html
  12 threads and 400 connections
  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: 577891
Requests/sec:  19202.50
Transfer/sec:      6.26MB
The results demonstrate that the requested pressure measured average delay Latency, the average number of requests per second per thread Req / Sec, the total number of requests per second Requests / sec throughput per second and Transfer / sec and the like. These data probably reflect the response of the pressure to measure server to server performance to make a preliminary judgment.

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.
On short and long connection connection: apache bench Default Short connection, wrk default long connection. To test wrk short connection, may be added -H "Connection: Close" to close the long link.

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:

wrk -t4 -c2000 -d60s -T5s --script=post.lua --latency http://127.0.0.1:80/user/login

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.

 

Guess you like

Origin www.cnblogs.com/eflypro/p/12420181.html