That is most certainly strange. Personally I would suspect the cURL module first since PHP and Apache are specifically designed to run in parallel. Perhaps it&#39;s implemented in such a way that PHP speaks to only one cURL process, that&#39;s possible, although I&#39;d call that a catastrophic design flaw if that were the case.<div>
<br></div><div>PHP&#39;s cURL library can however do asynchronous requests, even from a single PHP execution. While it&#39;s arguably not a proper solution to the weirdness of your problem, you may have more luck with it.</div>
<div><br></div><div>Here&#39;s one tutorial that I found and looks promising:</div><div><br></div><div><a href="http://www.phpied.com/simultaneuos-http-requests-in-php-with-curl/">http://www.phpied.com/simultaneuos-http-requests-in-php-with-curl/</a></div>
<div><div><br><div class="gmail_quote">Hope it helps! Let us know. :)</div><div class="gmail_quote"><br></div><div class="gmail_quote">Kind regards,</div><div class="gmail_quote">Helgi Hrafn Gunnarsson</div><div class="gmail_quote">
<a href="mailto:helgi@binary.is">helgi@binary.is</a></div><div class="gmail_quote"><br></div><div class="gmail_quote">On Tue, Mar 15, 2011 at 4:02 PM, John Lange <span dir="ltr">&lt;<a href="mailto:john@johnlange.ca">john@johnlange.ca</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I have some code (written in PHP) that checks on the status of a<br>
single &quot;server&quot; but I need this code to scale up to hundreds of<br>
parallel checks.<br>
<br>
For example, you call the script like this:<br>
<br>
<a href="http://mytest.com/checkserver.php?ip=10.11.12.13" target="_blank">http://mytest.com/checkserver.php?ip=10.11.12.13</a><br>
<br>
where the ip=X.X.X.X is different every time depending on which server<br>
you are checking.<br>
<br>
And the PHP looks something like this:<br>
<br>
&lt;?php<br>
<br>
$ch = curl_init();<br>
curl_setopt($ch, CURLOPT_URL, &quot;http://&quot;.$ip.&quot;/status.html&quot;);<br>
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);<br>
$output = curl_exec($ch);<br>
curl_close($ch);<br>
<br>
?&gt;<br>
<br>
To my way of thinking, this should scale easily. Lets say 200 people<br>
hit the page at the same time all passing different &quot;ip=&quot; values, this<br>
should check all 200 different servers in parallel and return results.<br>
<br>
It doesn&#39;t. I wrote this little bash script to test it (yes I&#39;m using<br>
command line curl to test php-curl, please don&#39;t be confused by that):<br>
---<br>
#!/bin/bash<br>
<br>
IPS=&quot;10.18.136.20<br>
10.18.136.21<br>
10.18.136.22<br>
... ( a hundred more IPs)&quot;<br>
<br>
for IP in $IPS ; do<br>
  curl -s <a href="http://mytest.com/checkserver.php?ip=$IP" target="_blank">http://mytest.com/checkserver.php?ip=$IP</a> &amp;<br>
done<br>
---<br>
<br>
All the curl commands launch into the background as you expect and I<br>
see all the apache child threads startup, but the results return one<br>
by one.<br>
<br>
I can&#39;t for the life of me figure out how this can be possible. Each<br>
apache thread should run it&#39;s PHP in a separate thread and return in<br>
parallel. The only thing I can think of is that php is tracking all<br>
the requests as being part of the same session and imposing some limit<br>
on the outbound curl requests... Or maybe it&#39;s apache blocking it?<br>
<br>
Just thought someone might have had to do something similar in the<br>
past and run into this.<br>
<br>
By the way, if I go direct like this:<br>
<br>
for IP in $IPS ; do<br>
  curl -s http://&quot;.$IP&quot;/status.html &amp;<br>
done<br>
<br>
It works just exactly as you&#39;d expect, all results return in parallel<br>
so it&#39;s got to be a problem with either PHP or apache.<br>
<font color="#888888"><br>
--<br>
John Lange<br>
<a href="http://www.johnlange.ca" target="_blank">www.johnlange.ca</a><br>
_______________________________________________<br>
Roundtable mailing list<br>
<a href="mailto:Roundtable@muug.mb.ca">Roundtable@muug.mb.ca</a><br>
<a href="http://www.muug.mb.ca/mailman/listinfo/roundtable" target="_blank">http://www.muug.mb.ca/mailman/listinfo/roundtable</a><br>
</font></blockquote></div><br></div></div>