Wrk: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
Line 82: Line 82:
* [http://czerasz.com/2015/07/19/wrk-http-benchmarking-tool-example/ wrk » LuaJIT » Advanced Example]
* [http://czerasz.com/2015/07/19/wrk-http-benchmarking-tool-example/ wrk » LuaJIT » Advanced Example]
* [https://github.com/wg/wrk/tree/master/scripts wrk » LuaJIT » Example Scripts]
* [https://github.com/wg/wrk/tree/master/scripts wrk » LuaJIT » Example Scripts]
* [https://github.com/wg/wrk/issues/189 wrk » LuaJIT » Simple Scenario]
* [https://github.com/wg/wrk/issues/189 wrk » LuaJIT » Simple Scenario]
* [https://github.com/wg/wrk wrk » HTTP benchmarking tool]
* [https://github.com/wg/wrk wrk » HTTP benchmarking tool]
* [https://medium.com/@felipedutratine/intelligent-benchmark-with-wrk-163986c1587f wrk » Intelligent benchmark]
* [https://medium.com/@felipedutratine/intelligent-benchmark-with-wrk-163986c1587f wrk » Intelligent benchmark]
Line 90: Line 90:


| valign="top" |
| valign="top" |
* [https://www.networknt.com/tool/wrk-perf/ wrk » LuaJIT » Performance Test]


| valign="top" |
| valign="top" |

Revision as of 16:59, 15 January 2024

# macos
brew install wrk
wrk --help

# debian / ubuntu
sudo apt install build-essential libssl-dev git -y
git clone https://github.com/wg/wrk.git && cd wrk
sudo make && sudo cp wrk /usr/local/bin
ls -lah /usr/local/bin|grep wrk
sudo make clean
wrk --help

Wrk Options

wrk -t 6 -c 200 -d 30s --latency https://google.com

: <<'EOC'
Usage: wrk <options> <url>                            
  Options:                                            
    -c, --connections <N>  Connections to keep open   
    -d, --duration    <T>  Duration of test           
    -t, --threads     <N>  Number of threads to use   
                                                      
    -s, --script      <S>  Load Lua script file       
    -H, --header      <H>  Add header to request      
        --latency          Print latency statistics   
        --timeout     <T>  Socket/request timeout     
    -v, --version          Print version details      
                                                      
  Numeric arguments may include a SI unit (1k, 1M, 1G)
  Time arguments may include a time unit (2s, 2m, 2h)
EOC

For connections and threads, the author suggest using thread number less than the core in CPU. The connections are shared in different threads, i.e., each threads get N = connections/threads connections.

Playground

cat <<'EOF' > ~/Documents/wrk-playground/test-urlencoded-data.lua
wrk.method = "POST"
wrk.body = "width=2&height=2"
wrk.headers['Content-Type'] = "application/x-www-form-urlencoded"
EOF

wrk -t 4 -c 100 -d 180s\
 -s ~/Documents/wrk-playground/test-urlencoded-data.lua\
 --latency "http://server_ip:1234/demo"
cat <<'EOF' > ~/Documents/wrk-playground/test-application-json.lua
wrk.method = "POST"
wrk.body = '{"width": 2, "height": 2}'
wrk.headers['Content-Type'] = "application/json"
EOF

wrk -t 4 -c 100 -d 180s\
 -s ~/Documents/wrk-playground/test-application-json.lua\
 --latency "http://server_ip:1234/demo"

References