Skip to content

Instantly share code, notes, and snippets.

@tomharvey
Last active March 8, 2021 11:17
Show Gist options
  • Save tomharvey/d98a5ddc2ef498d6a71972d9ca55c7e5 to your computer and use it in GitHub Desktop.
Save tomharvey/d98a5ddc2ef498d6a71972d9ca55c7e5 to your computer and use it in GitHub Desktop.
A dockerfile to install wrk2 https://github.com/giltene/wrk2
FROM ubuntu:focal
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential libreadline-dev curl unzip git libssl-dev libz-dev
RUN curl -R -O http://www.lua.org/ftp/lua-5.3.5.tar.gz && \
tar -zxf lua-5.3.5.tar.gz && \
cd lua-5.3.5 && \
make linux test && \
make install
RUN curl -R -O https://luarocks.github.io/luarocks/releases/luarocks-3.5.0.tar.gz && \
tar -xzvf luarocks-3.5.0.tar.gz && \
cd luarocks-3.5.0 && \
./configure && make bootstrap
RUN git clone https://github.com/giltene/wrk2.git && \
cd wrk2/ && \
make && pwd && \
ln -s /wrk2/wrk /usr/local/bin/wrk
ENTRYPOINT [ "wrk" ]
CMD ["--version"]
@tomharvey
Copy link
Author

Create a Dockerfile with these contents and run docker build -t wrk2:latest .

Once the image has been built you can run something like

$ docker run wrk2:latest -d 60s -R 2 https://example.com

Running 1m test @ https://example.com
  2 threads and 10 connections
  Thread calibration: mean lat.: 97.212ms, rate sampling interval: 429ms
  Thread calibration: mean lat.: 96.369ms, rate sampling interval: 429ms
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    27.94ms    3.32ms  44.32ms   80.00%
    Req/Sec     0.96      3.10    11.00     91.30%
  122 requests in 1.00m, 104.61KB read
  Socket errors: connect 0, read 0, write 0, timeout 170
Requests/sec:      2.03
Transfer/sec:      1.74KB

to send 2 requests per second for 1 minute at your testing endpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment