Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use cURL to perform multiple simultaneous requests?

Tags:

curl

request

I'd like to use cURL to test flood handling on my server. Right now I'm using this on a Windows command line:

curl www.example.com 

which will GET the page once. I'd like to now do the same thing, except instead of one request, I want to generate at least 10 requests at once. How would I do this?

like image 799
Daniel T. Avatar asked Mar 08 '12 21:03

Daniel T.


People also ask

How do I run multiple curl requests in parallel?

The solution to this is to use the xargs command as shown alongside the curl command. The -P flag denotes the number of requests in parallel. The section <(printf '%s\n' {1.. 10}) prints out the numbers 1 – 10 and causes the curl command to run 10 times with 5 requests running in parallel.


1 Answers

While curl is a very useful and flexible tool, isn't intended for this type of use. There are other tools available which will let you make multiple concurrent requests to the same URL.

ab is a very simple yet effective tool of this type, which works for any web server (despite the introduction focusing on Apache server).

Grinder is a more sophisticated tool, which can let you specify many different URLs to use in a load test. This lets you mix requests for cheap and expensive pages, which may more closely resemble standard load for your website.

like image 114
sgmorrison Avatar answered Oct 17 '22 03:10

sgmorrison