Wrk: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
No edit summary
 
(20 intermediate revisions by the same user not shown)
Line 1: Line 1:
<source lang="bash">
<syntaxhighlight lang="bash">
# macos
# macos
brew install wrk
brew install wrk
Line 11: Line 11:
sudo make clean
sudo make clean
wrk --help
wrk --help
</source>
</syntaxhighlight>
 
==Wrk Options==
<syntaxhighlight lang="bash">
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
</syntaxhighlight>
 
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==
{|
| valign="top"|
<syntaxhighlight lang="bash">
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"
</syntaxhighlight>
 
| valign="top" |
<syntaxhighlight lang="bash">
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"
</syntaxhighlight>
 
|-
| colspan="2" |
----
|-
| valign="top" |
 
| valign="top" |
 
|}


==References==
==References==
{|
{|
| valign="top" |
| valign="top" |
* [https://stackoverflow.com/questions/68465947/ wrk » LuaJIT » Generate Multiple POST Requests]
* [https://stackoverflow.com/questions/73938551/ wrk » LuaJIT » Test a Sequence of Requests]
* [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/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]
* [https://github.com/wg/wrk/tree/master/scripts wrk » GitHub » Scripts]
* [https://github.com/wg/wrk/blob/master/SCRIPTING wrk » LuaJIT » Scripting]
* [https://formulae.brew.sh/formula/wrk wrk » Homebrew]
* [https://formulae.brew.sh/formula/wrk wrk » Homebrew]
* [https://www.linkedin.com/company/thewrkco wrk » LinkenIn]
* [https://www.linkedin.com/company/thewrkco wrk » LinkenIn]
* [[Homebrew]]
* [[JQ Tool]]
* [[LuaJIT]]


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


| valign="top" |
| valign="top" |
Line 34: Line 99:
|-
|-
| valign="top" |
| valign="top" |
* [[Homebrew]]
* [[ZA Proxy]]
* [[Cypress]]
* [https://gatling.io/ Gatling]
* [[HTTPie]]
* [[JQ Tool]]
* [[Locust]]
* [[JMeter]]
* [[LuaJIT]]
* [[Lua]]


| valign="top" |
| valign="top" |
* [https://k6.io/open-source/ K6 Open Source]
* [[CURL]]


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


|}
|}

Latest revision as of 19:37, 22 April 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