So I've been messing a lot with Curl just to understand as much about it as I can. I was able to get the results I want on my localhost using xampp. When I run 100 requests, I get it down 6.3 seconds. Which is perfectly fine for me. My localhost I'm using PHP 5.5.11.
But then when I moved to my shared server using PHP 5.5.37 running the same 100 requests from the same site takes 37 seconds. The issue I have found is the curl_multi_select function. I have put timestamps around all the blocks and the only thing that is taking 6-7 seconds to complete is the code around curl_multi_select.
while ($active && $mrc == CURLM_OK) {
if (curl_multi_select($this->MH) == -1) {
//give time to process otherwise you get caught in a loop
usleep(100);
}
do {
$mrc = curl_multi_exec($this->MH, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
}
Usually my localhost is slower than shared server, so I don't know exactly what is going on here. Here is a list of options I'm sending curl just in case you see something that can be causing an issue. They are in lower case but a function turns them in to the correct constants.
$this->opts = Array(
'url' => ''
,'returntransfer' => 1
,'followlocation' => 1
,'header' => 0
,'post' => false
,'ipresolve' => 'CURL_IPRESOLVE_V4'
,'timeout' => 10
,'connecttimeout' => 5
,'verbose' => true
,'useragent' => $_SERVER['HTTP_USER_AGENT']
,'httpheader' => null
,'encoding' => ''
,'ssl_verifypeer' => false
,'ssl_verifyhost' => false
);
It just annoys me I've got it to work on my local host to a point that I can definitely use. But 30+ seconds on the shared server that I want to use is just too much. And I've tried for days to get this to work myself. Just hoping someone can pick something out here that I'm missing. Any help will be appreciated.