I'm trying to take a list of 40,000 items and run a json request for each item. The process is super slow which I suspect is because each json request is finishing before the next request starts.
$result = mysql_query("SELECT * FROM $tableName");
while($row = mysql_fetch_array($result))
{
checkRank($row['Domain']);
}
checkRank is running something to the effect of:
$json = file_get_contents($jsonurl,0,null,null);
I'm thinking I could run 10 checkRanks at a time to speed the process up? Any other ideas / suggestions?
UPDATE:
For example this loop runs through my array in 27 secs.
for ($i=0; $i<=100; $i++) {
checkRank($domains[$i]);
$i++;
checkRank($domains[$i]);
$i++;
checkRank($domains[$i]);
$i++;
checkRank($domains[$i]);
$i++;
checkRank($domains[$i]);
$i++;
echo "checking " . $i . "<br/>";
}
The loop below takes over 40 seconds with the same array.
for ($i=0; $i<=100; $i++) {
checkRank($domains[$i]);
echo "checking " . $i . "<br/>";
}