Created
March 3, 2016 11:03
-
-
Save bigomega/4de7dbc395be0e0f33b4 to your computer and use it in GitHub Desktop.
A simple bash script to do load (performance) testing of a web service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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
@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
Hello,
I'm trying to test the script and get error see below
$ ./load-test.sh http://google.com
Tue, Apr 17, 2018 12:17:45 AM
rate: http://google.com calls / second'
url:
rate: http://google.com calls / second
++ date +%s
++ date +%s
0:0
++ seq 1 http://google.com
seq: invalid floating point argument: ‘http://google.com’
Try 'seq --help' for more information.
++ date +%s
0:1
++ seq 1 http://google.com
can you advise what is wrong?