how do we repeat the below command to fire 100's of same request on my bash terminal?
http GET welcomer.loreans.com/welcome
http is from httpie(https://httpie.org/)
how do we repeat the below command to fire 100's of same request on my bash terminal?
http GET welcomer.loreans.com/welcome
http is from httpie(https://httpie.org/)
Another version of your linear solution:
for i in `seq 1 100`; do http GET welcomer.loreans.com/welcome; done
As far as URL Requests are concerned, GNU Parallel is more suitable for your task.
Straight from the man page:
GNU parallel is a shell tool for executing jobs in parallel using one or more computers. The typical input is a list of files, a list of hosts, a list of users, a list of URLs, or a list of tables.
So if you want the request to originate from different computers, you can adapt the following command which uses only one computer.
parallel http GET welcomer.loreans.com/welcome ::: `seq 1 100`
Unlike the ampersand solution, this will not bring your laptop to its knees if you increase drastically the number of requests you want.
Here's a little bit of a twist on this task. Here's code to run that query 100 times in parallel:
seq 1 100 | xargs -I% -P100 http GET welcomer.loreans.com/welcome
And here's similar code to run the tasks parallel, but without xargs:
for i in $(seq 1 100)
do
http GET welcomer.loreans.com/welcome &
done
wait
As you can see, the for loop has been augmented with an ampersand to execute the http GET in the background. Moreover, a wait is added to the end to tell the bash script to wait for all of the child processes to exit.