title: Bad performance in the cURL call on the same server
body: <p>Why just few concurrency can cause block when cURL call on the same server</p>
  
  <h2>Example</h2>
  
  <p>phpdebug.com</p>
  
  <pre><code>&lt;?php
  $curl = curl_init();
  curl_setopt_array($curl, array(
    CURLOPT_URL =&gt; "http://phpdebug2.com",
    CURLOPT_RETURNTRANSFER =&gt; true,
    CURLOPT_ENCODING =&gt; "",
    CURLOPT_MAXREDIRS =&gt; 10,
    CURLOPT_TIMEOUT =&gt; 30,
    CURLOPT_HTTP_VERSION =&gt; CURL_HTTP_VERSION_1_1
  ));
  $response = curl_exec($curl);
  $err = curl_error($curl);
  curl_close($curl);
  if ($err) {
    echo "cURL Error #:" . $err;
  } else {
    echo $response;
  }
  </code></pre>
  
  <p>phpdebug2.com</p>
  
  <pre><code>&lt;?php
  echo "application2";
  </code></pre>
  
  <h2>Apache ab  test result</h2>
  
  <pre><code>ab -n 10 -c 2 http://phpdebug.com/
  
  Requests per second:    198.93 [#/sec] (mean) 
  Time per request:       10.054 [ms] (mean) 
  Time per request:       5.027 [ms] (mean, across all concurrent requests) 
  Transfer rate:          33.80 [Kbytes/sec] received
  </code></pre>
  
  <hr>
  
  <pre><code>ab -n 10 -c 3 http://phpdebug.com/
  
  Requests per second:    60.42 [#/sec] (mean)
  Time per request:       49.648 [ms] (mean)
  Time per request:       16.550 [ms] (mean, across all concurrent requests)
  Transfer rate:          10.27 [Kbytes/sec] received
  </code></pre>
  
  <hr>
  
  <pre><code>ab -n 10 -c 4 http://phpdebug.com/
  
  Requests per second:    17.68 [#/sec] (mean)
  Time per request:       226.226 [ms] (mean)
  Time per request:       56.557 [ms] (mean, across all concurrent requests)
  Transfer rate:          3.00 [Kbytes/sec] received
  </code></pre>
  
  <hr>
  
  <pre><code>ab -n 10 -c 5 http://phpdebug.com/
  
  Benchmarking phpdebug.com (be patient)...apr_pollset_poll: The timeout specified has expired (70007)
  </code></pre>
  
  <ol>
  <li>Why the <strong>Requests per second</strong> drop so fast?</li>
  <li>How to optimize this situation when cURL call on the same server?</li>
  </ol>