I was testing my code to check how it will behave if we think that 100 users submitted their registration all at once !!!
My code is in PHP Laravel 5.2 and JQuery Ajax is below.
for (i = 0; i < 100; i++) {
var
data={'Role' : "Role"+i},
request = $.ajax({
url: 'http://localhost:1234/Practise/public/api/SaveRoleApi',
type: "POST",
data: JSON.stringify(data),
contentType: "application/json; charset=utf-8",
async: true,
success: function(d){ console.log(d); }
});
}
Out of 100, I am not successful in submitting more then 88 records.
I am using MySQL Database.
if my above code will add records sequentially...id there any way to test 1000 concurrent requests from one computer?
Attempting multiple requests from one browser using JavaScript to create all the connections is not a good idea, you are indeed not testing concurrency very well.
Consider using an actual load testing tool like JMeter (I definitely recommend this), or at least parallel curl requests in a batch script.
for n in {1..1000}; do
for i in `eval echo {$n..$((n+999))}`; do
echo "club $i..."
curl -X POST -H "Content-Type: application/json" -d '{"param1":"xyz","param2":"xyz"}' -s "http://localhost:1234/Practise/public/api/SaveRoleApi" >> log.txt
done &
wait
done
I would propose to use a tool specific for this purpose like loader. Keep in mind that your web app should be accessible from the outer world.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With