Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script that replicates the traffic being generated by the TechEmpower JSON serving benchmark.
#!/bin/sh
HOST=localhost
PORT=9090
URL=/json
CONTENT_TYPE_HEADER="application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7"
CONNECTION_HEADER="Connection: keep-alive"
# Parameters:
# $1 = duration
# $2 = connections
# $3 = threads
function work {
wrk -H 'Host: $HOST' -H '$CONTENT_TYPE_HEADER' -H '$CONNECTION_HEADER' --latency -d $1 -c $2 --timeout 8 -t $3 http://$HOST:$PORT$URL
}
# Primer
echo ===============
echo Primer Requests
echo ===============
work 5 8 8
# Sleep between
sleep 3
# Warmup
# wrk -H 'Host: localhost' -H 'application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' -H 'Connection: keep-alive' --latency -d 15 -c 256 --timeout 8 -t 2 http://127.0.0.1:9090/json
echo ===============
echo Warmup Requests
echo ===============
work 15 256 2
# Sleep between
sleep 3
# Concurrency 8
# wrk -H 'Host: localhost' -H 'application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' -H 'Connection: keep-alive' --latency -d 15 -c 8 --timeout 8 -t 2 http://127.0.0.1:9090/json
echo ===============
echo Concurrency 8
echo ===============
work 15 8 2
# Sleep between
sleep 3
# Concurrency 16
# wrk -H 'Host: localhost' -H 'application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' -H 'Connection: keep-alive' --latency -d 15 -c 16 --timeout 8 -t 2 http://127.0.0.1:9090/json
echo ===============
echo Concurrency 16
echo ===============
work 15 16 2
# Sleep between
sleep 3
# Concurrency 32
# wrk -H 'Host: localhost' -H 'application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' -H 'Connection: keep-alive' --latency -d 15 -c 32 --timeout 8 -t 2 http://127.0.0.1:9090/json
echo ===============
echo Concurrency 32
echo ===============
work 15 32 2
# Sleep between
sleep 3
# Concurrency 64
# wrk -H 'Host: localhost' -H 'application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' -H 'Connection: keep-alive' --latency -d 15 -c 64 --timeout 8 -t 2 http://127.0.0.1:9090/json
echo ===============
echo Concurrency 64
echo ===============
work 15 64 2
# Sleep between
sleep 3
# Concurrency 128
# wrk -H 'Host: localhost' -H 'application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' -H 'Connection: keep-alive' --latency -d 15 -c 128 --timeout 8 -t 2 http://127.0.0.1:9090/json
echo ===============
echo Concurrency 128
echo ===============
work 15 128 2
# Sleep between
sleep 3
# Concurrency 256
# wrk -H 'Host: localhost' -H 'application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' -H 'Connection: keep-alive' --latency -d 15 -c 256 --timeout 8 -t 2 http://127.0.0.1:9090/json
echo ===============
echo Concurrency 256
echo ===============
work 15 256 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.