From 0bea8f2eb026e623a4dd6c90888d0b167156e3af Mon Sep 17 00:00:00 2001 From: Oliver Ladner Date: Thu, 2 Nov 2023 09:46:25 +0100 Subject: [PATCH] add apachebench benchmarking and graphing --- apachebench/README.md | 10 ++++++++++ apachebench/ab.sh | 9 +++++++++ apachebench/plot_ttfb.sh | 21 +++++++++++++++++++++ apachebench/plot_ttime.sh | 21 +++++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 apachebench/README.md create mode 100755 apachebench/ab.sh create mode 100755 apachebench/plot_ttfb.sh create mode 100755 apachebench/plot_ttime.sh diff --git a/apachebench/README.md b/apachebench/README.md new file mode 100644 index 0000000..2a54ca3 --- /dev/null +++ b/apachebench/README.md @@ -0,0 +1,10 @@ +# ab (apache bench) and Gnuplot +Two scripts: + +* `ab.sh` runs your ab benchmark. Specifiy requests, concurrency and URL +* `plot_ttime.sh` generates graphs with Gnuplot (total time) +* `plot_ttfb.sh` generates graphs with Gnuplot (Time To First Byte) + +Web links: + +* [Apache Bench and Gnuplot: you’re probably doing it wrong](http://www.bradlanders.com/2013/04/15/apache-bench-and-gnuplot-youre-probably-doing-it-wrong/) diff --git a/apachebench/ab.sh b/apachebench/ab.sh new file mode 100755 index 0000000..b606931 --- /dev/null +++ b/apachebench/ab.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +reqs=100000 +concurrency=10 +url='http://swiss-igr-lb-1579447362.eu-west-1.elb.amazonaws.com/en/' +fileprefix='swiss-igr' +useragent="Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1 Unic Loadtest" + +# apache bench with basic authentication +ab -A username:password -H "User-Agent: $useragent" -n $reqs -c $concurrency -g ${fileprefix}_$(date +%F_%H%M%S)_r-${reqs}_c-${concurrency}.gnuplot $url > ${fileprefix}_$(date +%F_%H%M%S)_r-${reqs}_c-${concurrency}.log diff --git a/apachebench/plot_ttfb.sh b/apachebench/plot_ttfb.sh new file mode 100755 index 0000000..f6ab750 --- /dev/null +++ b/apachebench/plot_ttfb.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +for file in $(ls -1 swiss*\.gnuplot); do + gnuplot <<- EOF + set terminal png size 1280,500 + set size 1, 1 + set output "$file\_ttfb.png" + set title "$file" + set key left top + set grid y + set xdata time + set timefmt "%s" + set format x "%H:%M:%S" + set xlabel 'time' + set ylabel "response time (ms)" + set yrange [0:10000] + set datafile separator '\t' + plot "$file" every ::2 using 2:6 title 'response time (TTFB)' with points + exit + EOF +done diff --git a/apachebench/plot_ttime.sh b/apachebench/plot_ttime.sh new file mode 100755 index 0000000..01850b5 --- /dev/null +++ b/apachebench/plot_ttime.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +for file in $(ls -1 swiss*\.gnuplot); do + gnuplot <<- EOF + set terminal png size 1280,500 + set size 1, 1 + set output "$file\_ttime.png" + set title "$file" + set key left top + set grid y + set xdata time + set timefmt "%s" + set format x "%H:%M:%S" + set xlabel 'time' + set ylabel "response time (ms)" + set yrange [0:10000] + set datafile separator '\t' + plot "$file" every ::2 using 2:5 title 'response time (total)' with points + exit + EOF +done