In my application I need to do 1000 and sometimes even more CURL requests to the same URL. So each time i do a foreach loop and send the data one by one:
foreach ($data as $id => $value) {
$queryUpdate = [
'id' => $id,
'data' => [
'ref_id' => $value['id'],
'name' => $value['title'],
'description' => $value['desc'],
]
];
curl_setopt_array($ch, array(
CURLOPT_URL => 'https://test/blabla/bla',
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => http_build_query(
$queryUpdate
),
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
"Accept: application/json",
"Content-type: application/x-www-form-urlencoded"
),
));
$response = curl_exec($ch);
$rsp = json_decode($response, true);
if ($rsp['response']['status'] != 1) {
var_dump($rsp);
die;
}
echo "$i) Updated at" . date("h:i:s") . "<br />";
$i++;
}
curl_close($ch);
So it takes around 3-4 mins to do 200 requests. After 5mins I get timeout from curl(because i exceed 300seconds).
Now I can probably increase the timeout lenght I didnt look, but I need a different solution. A solution that would speed up all these curl proccesses. Is there a way?