Simple Load Testing with curl
By Pete Freitag

Recently I was testing a client's rate limiting configuration, so I needed to send a bunch of requests to a URL within a short period of time to see if it was working properly. I wrote up a quick bash script to loop from 1 to 20 with curl requests and sleeping for a short period between each request.
I thought it would be pretty easy to make the url, number of requests and delay command line arguments. It was, and I now have a handy general purpose tool for making repeated requests with curl. You can run the tool like this:
load.sh http://example.com/ 5 1
And it will make 5 requests to example.com with a 1 second delay between each http request. Here's the output
Hitting http://example.com with 5 requests with 0.5 delay Response 1 200 0.207889s Response 2 200 0.184135s Response 3 200 0.188796s Response 4 200 0.100910s Response 5 200 0.097209s 5/5 Sent
The script will output the http response status code and the time taken for each request.
Here's the bash script, I call load.sh
:
#!/bin/bash if [ $# -lt 1 ]; then echo "Usage: $0 url [requests] [delay]" exit 1 fi test_url="$1" requests="${2:-1}" delay="${3:-0}" if ! [[ "$requests" =~ ^[0-9]+$ ]] || [ "$requests" -lt 1 ] || [ "$requests" -gt 1000 ]; then echo "Error: requests must be an integer between 1 and 1000" exit 1 fi echo "Hitting $test_url with $requests requests with $delay delay" for ((num=1;num<=$requests;num++ )) do curl $test_url -o /dev/null -w "Response $num %{http_code} %{time_total}s\n" -s & sleep $delay done echo "$requests/$requests Sent" wait
You'll want to save the above as load.sh
then chmod a+x load.sh
.
The first part of the script is really just putting the arguments into variables and doing a quick check on the number of requests to make sure you don't create an infinite loop by accident. Then we have a bash for loop that goes from 1 to the number of requests specified. For each iteration of the loop curl is invoked, and I use the ampersand &
at the end to put the curl process in the background. This is the entire key to the script working, it allows you to send concurrent requests, and acheive a somewhat steady request rate. Finally at the end of the script I call wait
which waits for my background commands to finish before exiting the program.
I wrote and tested this script on a Mac, but it should also work just fine on Linux or on Windows with WSL.
Simple Load Testing with curl was first published on June 19, 2025.