I am using curl_multi_exec() to get data from some APIs and using the following code :
$startTime = microtime(true);
$running = null;
do
{
curl_multi_exec ( $curlMultiHandleResource, $running );
usleep(50000);
}
while ( $running > 0 );
$runningTime = microtime(true)-$startTime;
and I have set CURLOPT_TIMEOUT_MS = 1800 and CURLOPT_CONNECTTIMEOUT_MS = 1800. On my windows machine $runningTime is always around 1.8 secs or lesser but on linux machine it sometimes comes out to be even more than 2.5 secs. So I wanted to know why is this taking longer than CURLOPT_TIMEOUT_MS?
EDIT : I narrowed down the problem somewhat. I echoed the time taken in the call to curl_multi_exec() and found that every time in the second iteration of while loop it is taking longer than usual. Usually it is taking 10^-3 to 10^-5 seconds but in second iteration it is taking 0.5 to 1.5 seconds.