The following code will cause serious performance problem:
do {
$status = curl_multi_exec($multihandle, $active);
}
while ($status === CURLM_CALL_MULTI_PERFORM);
it will be much better if changed as follow
do {
$status = curl_multi_exec($multihandle, $active);
usleep(1000);
}
while ($status === CURLM_CALL_MULTI_PERFORM);