PHP / curl: namelookup_time / dns slows down requests

EDIT: Found part of the reason - see bottom.

I am making a standard curl call from php. However, while resolving the name, it seems to freeze. In my OSX, the namelookup_time field lasts more than 1 second for this and other requests to the same subnet. The linux box on my subnet doing the same request has a 0.02 second response to a different subnet, so this is a problem with my box.

This is a problem because our application makes many calls to this subnet to create the page, so the seconds add up.

My curl_getinfo request (url burst out)

array
  'url' => string ' < SNIPPED > '... (length=1449)
  'content_type' => string 'text/plain; charset=utf-8' (length=25)
  'http_code' => int 200
  'header_size' => int 227
  'request_size' => int 1480
  'filetime' => int -1
  'ssl_verify_result' => int 0
  'redirect_count' => int 0
  'total_time' => float 1.165444
  'namelookup_time' => float 1.001272
  'connect_time' => float 1.017765
  'pretransfer_time' => float 1.017781
  'size_upload' => float 0
  'size_download' => float 92562
  'speed_download' => float 79422
  'speed_upload' => float 0
  'download_content_length' => float 92562
  'upload_content_length' => float 0
  'starttransfer_time' => float 1.043094
  'redirect_time' => float 0
  'certinfo' => 
    array
      empty
  'redirect_url' => string '' (length=0)

I have a suspicion that the lag in the name lookup is related to IPv6, so I tried the following:

1) , Ipv6 OSX, . IPv6 , .

http://community.centrify.com/t5/Express-for-Mac-Tips-and-Tricks/Using-local-domains-with-Centrify-Directcontrol-on-the-Mac/ba-p/3724

, Mac IPv6 : http://ipv6test.google.com/.

2) PHP --disable-ipv6.

php -i : IPv6 = >

curl : "IPv6 = > ", , .

3) Ran curl:

curl_setopt ($ c, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);

, - 1 + . - , , ?:)

( - googled SO'ed , ..)

: ckhan :
1) 1 + namelookup_time, IP- :

'url' => string 'HTTP://172.19.105.171:8070  <SNIPPED> '... (length=1439)
...
'namelookup_time' => float 1.001309

2) :

# url.txt has the same url as the above curl call
time cat url.txt |xargs curl
<... response output ...>
real  0m0.053s
user  0m0.009s
sys 0m0.008s

3), , .

dig 172.19.105.171
...
;; Query time: 77 msec
...

:
PHP 5.3.8
OSX 10.7.3

curl_multi_select, - 1 . 0,00005 . , . , , Linux OSX php/libcurl, (5.3.8).

+3
1

PHP curl_multi_select, - 1 . 0,00005 . , . , , Linux OSX php/libcurl, (5.3.8).

SO, curl_multi_select.

+2

All Articles