Reputation: 103
I have the following curl command: curl -i -H "Content-Type: text/plain" -X POST -d @hundredencoded http:///aaa/bbb/message
For load testing, i need to run this command 100 times, how do i do it using CURL?
Thanks in advance.
Upvotes: 10
Views: 22334
Reputation: 3670
You could achieve it by using the below script:
#!/bin/bash
for i in $(eval echo {1..$1})
do
curl -i -H 'Content-Type: text/plain' -X POST -d @hundredencoded http:///aaa/bbb/message &
done
Upvotes: 16
Reputation: 397
Although the question specify using curl for this task, I would highly recommend using ab for this.
ab (Apache Benchmark) is a tool build specifically for the case in question. It allows you to call a specific request multiple times and also define concurrency. http://httpd.apache.org/docs/2.0/programs/ab.html
Your test would be:
ab -p post.txt -H 'Content-Type: text/plain' -n 100 -c 1 http://aaa/bbb/message
or, even shorter:
ab -p post.txt -T text/plain -n 100 -c 1 http://aaa/bbb/message
Where the file post.txt
holds the POST data.
Upvotes: 10