I have a script that uses curl to download a webpage and waits for it to finish.
Code snipit:
curl_setopt($ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 0 );
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
$response = curl_exec( $ch );
$mh = curl_multi_init();
curl_multi_add_handle($mh,$ch);
$running=null;
curl_multi_exec($mh,$running);
while ($running > 0) {
curl_multi_exec($mh,$running);
sleep(5);
} ;
If users1 requests this page on webserver1 then it starts and usually takes a few minutes (the page it's requesting is on webserver2 and the page on webserver 2 takes a while to finish).
Then while user1 is waiting, if user2 comes along and requests any other page on webserver1 then user2 must wait until user1's page finishes.
I've done some testing and it only seems to happen with the page containing the code above. While user1 is requesting this page, 1.3% of the CPU is used (httpd is using the 1.3%) and only 261mb of 1024mb of RAM is being used (httpd only taking up up 1.6% of the RAM).
I'm a newbie to PHP.. The only thing I've tried is upping the allowed memory to 128M in php.ini (good or bad idea?).
Any suggestions?