what is the fastest way to get the http status code. I have a list within about 10k URL's to check. And in best case it checks them every 15 minutes. So i've a php script what uses simple curl functions and loop through them all. But it takes way too much time. Any suggestions what i can do to improve that? What about parallel checks on multiple urls? how many could php manage? I'm very new to this whole performance thing.
This is what i have:
public function getHttpStatus(array $list) {
$list = array(…); // Array contains 10k+ urls from database.
for($i = 0; $i < count($list); $i++) {
$ch = $list[$i];
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
$c = curl_exec($ch);
$info = curl_getinfo($ch);
echo $info['http_code'] . '<br />';
}
}
Thanks in advance!