Categories
Linux Mastering Development

Combine gnu-parallel and curl in Linux

I’m testing my webserver and sending API Thousand of request to optimize my program with high traffic. Indeed I write two bash-shells but they not fast as I want any one can help me on this and let me know how to modify them to execute fast as much as possible?

$ mycurl() { contents=$(< data.txt); eval "words=( $contents )"; arguments=(); for i in {1..1000}; 
do arguments+=( "${words[@]}" ); done; curl "${arguments[@]}"; }; 
$ export -f mycurl; 
$ seq 100 | parallel -j0 mycurl

and the second one is

$ for i in $(seq 100000); do cat data.txt; done | curl -K -

One way that I can run on my computer is the following but I am not sure it is the best way.

 mycurl() { parallel -j0 bash :::: <(ls job{1..2}.sh) };
 export -f mycurl;
 seq 10 | parallel -j0 mycurl;

Leave an answer

Your email address will not be published. Required fields are marked *