Optimize the performance of curl by using usleep() during the curl polling.
this will give the performance boost to your application
$CommonHandle = curl_multi_init();
for ($i = 1, $total = $activeCount; $i <= $total; $i++)
{
$Handle = curl_init();
curl_setopt($Handle, CURLOPT_URL, $Url);
curl_setopt($Handle, CURLOPT_HEADER, 0);
curl_multi_add_handle($CommonHandle, $Handle);
}
// Keep polling after an interval.
$isFinished = null;
do
{
curl_multi_exec($CommonHandle, $isFinished);
usleep(2000000); //wait for 2 seconds time in micro seconds
}
while ($isFinished > 0);
// To remove individual handles also from $CommonHandle.
curl_multi_close($CommonHandle);
No comments:
Post a Comment