Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A simple bash script to do load (performance) testing of a web service
max="$1"
date
echo "url: $2
rate: $max calls / second"
START=$(date +%s);
get () {
curl -s -v "$1" 2>&1 | tr '\r\n' '\\n' | awk -v date="$(date +'%r')" '{print $0"\n-----", date}' >> /tmp/perf-test.log
}
while true
do
echo $(($(date +%s) - START)) | awk '{print int($1/60)":"int($1%60)}'
sleep 1
for i in `seq 1 $max`
do
get $2 &
done
done
@amousa1968

This comment has been minimized.

Copy link

commented Apr 17, 2018

Hello,
I'm trying to test the script and get error see below
$ ./load-test.sh http://google.com

@MParvin

This comment has been minimized.

Copy link

commented Oct 27, 2018

Hello,
I'm trying to test the script and get error see below
$ ./load-test.sh http://google.com

* max=http://google.com

* date
  Tue, Apr 17, 2018 12:17:45 AM

* echo 'url:
  rate: http://google.com calls / second'
  url:
  rate: http://google.com calls / second
  ++ date +%s

* START=1523949465

* true

* awk '{print int($1/60)":"int($1%60)}'
  ++ date +%s

* echo 0
  0:0

* sleep 1
  ++ seq 1 http://google.com
  seq: invalid floating point argument: ‘[http://google.com’](http://google.com%E2%80%99)
  Try 'seq --help' for more information.

* true

* awk '{print int($1/60)":"int($1%60)}'
  ++ date +%s

* echo 1
  0:1

* sleep 1
  ++ seq 1 http://google.com
  can you advise what is wrong?

Your syntax is wrong
Enter max test count before URL
./load-test.sh 100 http://google.com

@sr2ds

This comment has been minimized.

Copy link

commented Mar 13, 2019

@MParvin and @amousa1968

Test this way:
curl -L https://goo.gl/S1Dc3R | bash -s 20 "http://server.com/api"

Ref: https://medium.com/@bigomega/simple-load-testing-script-in-bash-a8c5a4968dc7

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.