Skip to content

Instantly share code, notes, and snippets.

@sahilsk
Last active January 11, 2024 13:14
Show Gist options
  • Save sahilsk/370f895f50407e9fe4dc to your computer and use it in GitHub Desktop.
Save sahilsk/370f895f50407e9fe4dc to your computer and use it in GitHub Desktop.
Load and stress testing tools

wrk is a modern HTTP benchmarking tool capable of generating significant load when run on a single multi-core CPU. It combines a multithreaded design with scalable event notification systems such as epoll and kqueue.

Basic Usage

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

This runs a benchmark for 30 seconds, using 12 threads, and keeping 400 HTTP connections open.

Output:

Running 30s test @ http://127.0.0.1:8080/index.html
  12 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   635.91us    0.89ms  12.92ms   93.69%
    Req/Sec    56.20k     8.07k   62.00k    86.54%
  22464657 requests in 30.00s, 17.76GB read
Requests/sec: 748868.53
Transfer/sec:    606.33MB


wrk -c 500 -d 30 -t 1;

Vegeta is a versatile HTTP load testing tool built out of a need to drill HTTP services with a constant request rate. It can be used both as a command line utility and a library.

examples:

echo "GET http://localhost/" | vegeta attack -duration=5s | tee results.bin | vegeta report
vegeta attack -targets=targets.txt > results.bin
vegeta report -inputs=results.bin -reporter=json > metrics.json
cat results.bin | vegeta report -reporter=plot > plot.html
cat results.bin | vegeta report -reporter="hist[0,100ms,200ms,300ms]"

TARGET_URL="http://localhost"
echo "GET $TARGET_URL" | vegeta attack -duration=5s | tee results.bin | vegeta report
#echo "GET $TARGET_URL" | vegeta attack -rate=400/s -duration 5s | tee results.bin | vegeta plot > plot.html

With beautiful graph:

echo "GET https://fit-robin.practodev.com/api/feed?query=sex&page=1&limit=3" | vegeta attack -duration=10s  -rate=50 | tee results.bin | vegeta report --reporter=plot > /tmp/output-new-1.html

Distributed load (or attack)

pdsh -b -w '10.0.1.1,10.0.2.1,10.0.3.1' \
'echo "GET http://target/" | vegeta attack -rate=20000 -duration=60s > result.bin'

ab is a tool for benchmarking your Apache Hypertext Transfer Protocol (HTTP) server. It is designed to give you an impression of how your current Apache installation performs. This especially shows you how many requests per second your Apache installation is capable of serving.

The h2load program is a benchmarking tool for HTTP/2 and SPDY. The SPDY support is enabled if the program was built with the spdylay library. The UI of h2load is heavily inspired by weighttp (https://github.com/lighttpd/weighttp). The typical usage is as follows:

$ h2load -n100000 -c100 -m100 https://localhost:8443/
starting benchmark...
spawning thread #0: 100 concurrent clients, 100000 total requests
Protocol: TLSv1.2
Cipher: ECDHE-RSA-AES128-GCM-SHA256
Server Temp Key: ECDH P-256 256 bits
progress: 10% done
progress: 20% done
progress: 30% done
progress: 40% done
progress: 50% done
progress: 60% done
progress: 70% done
progress: 80% done
progress: 90% done
progress: 100% done

finished in 771.26ms, 129658 req/s, 4.71MB/s
requests: 100000 total, 100000 started, 100000 done, 100000 succeeded, 0 failed, 0 errored
status codes: 100000 2xx, 0 3xx, 0 4xx, 0 5xx
traffic: 3812300 bytes total, 1009900 bytes headers, 1000000 bytes data
                     min         max         mean         sd        +/- sd
time for request:    25.12ms    124.55ms     51.07ms     15.36ms    84.87%
time for connect:   208.94ms    254.67ms    241.38ms      7.95ms    63.00%
time to 1st byte:   209.11ms    254.80ms    241.51ms      7.94ms    63.00%

Goad is an AWS Lambda powered, highly distributed, load testing tool https://goad.io

eg. $ goad -n 1000 -c 5 -r us-east-1,eu-west-1 -m GET -u "https://goad.io"

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