cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

curl_multi and cpu time issues.

From: Brian Graves <briansspam_at_bellsouth.net>
Date: Wed, 06 Dec 2006 12:15:09 -0500

I have a PHP script that used to run on regular curl requests and
decided to switch to curl_multi for the speed benefits. With the script
only running for a few hours at the end of the day, my cpu time reports
from averaging around 45 minutes to 6 hours yesterday.

This is the only thing I changed in the last 24 hours, so I know the
curl_multi is the culprit. I can also see sharp jumps in processor time
right after I switched to curl_multi

Here's the code: (my script pulls from 5 sites)

$urlArray[0] = "http://website.com/";
$urlArray[1] = "http://anotherwebsite.com/";
$urlArray[2] = "http://andanother.com/";
$urlArray[3] = "http://onemore.com/";
$urlArray[4] = "http://lastone.com/";

$mh = curl_multi_init();

foreach ($urlArray as $i => $url) {
       $conn[$i]=curl_init($url);
       curl_setopt($conn[$i],CURLOPT_RETURNTRANSFER,1);
       curl_multi_add_handle ($mh,$conn[$i]);
}

do { $n=curl_multi_exec($mh,$active); } while ($active);

foreach ($urlArray as $i => $url) {
       $res[$i]=curl_multi_getcontent($conn[$i]);
       curl_close($conn[$i]);
}

Perhaps there's something wrong with my code? It seems to be in order.

What's the problem?

Thanks,
-Brian

PHP Version: 5.1.2

CURL Information libcurl/7.13.2 OpenSSL/0.9.7e zlib/1.2.2 libidn/0.5.13

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2006-12-06