Forum: NGINX Very slow dns lookup using proxy_pass

2974d09ac2541e892966b762aad84943?d=identicon&s=25 justin (Guest)
on 2014-01-04 04:43
(Received via mailing list)
I am seeing very slow DNS lookup times ( > 2 seconds ) using proxy_pass,
even though dig response times on the server are quick. Here is the
nginx
configuration block:

  location ~ ^/v1/(?<url>.*)  {
    resolver 8.8.4.4 4.4.4.4 valid=300s;
    resolver_timeout 10s;
    proxy_pass https://$remote_user.mydomain.com/api/;
    proxy_hide_header Vary;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_connect_timeout 10s;
    proxy_read_timeout 60s;
    proxy_ssl_session_reuse on;
  }

I am using Google Public DNS. Here is a result from: dig
demo.mydomain.com

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6_4.6 <<>> demo.mydomain.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37997
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;demo.mydomain.com.    IN  A

;; ANSWER SECTION:
demo.mydomain.com.  299  IN  A  X.X.X.X

;; Query time: 187 msec
;; SERVER: 8.8.4.4#53(8.8.4.4)
;; WHEN: Fri Jan  3 19:40:32 2014
;; MSG SIZE  rcvd: 50

Any ideas why this is so slow, and solutions?

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,246001,246001#msg-246001
34011bc56457235a2caa5ed1d4a29f3c?d=identicon&s=25 Jonathan Matthews (Guest)
on 2014-01-04 04:53
(Received via mailing list)
On 4 January 2014 03:42, justin <nginx-forum@nginx.us> wrote:
> I am seeing very slow DNS lookup times ( > 2 seconds ) using proxy_pass,
> even though dig response times on the server are quick
[snip]
> Any ideas why this is so slow, and solutions?

Please demonstrate a slow request, and show the data that leads you to
believe that DNS lookups from nginx are the problem.

Jonathan
2974d09ac2541e892966b762aad84943?d=identicon&s=25 justin (Guest)
on 2014-01-04 05:11
(Received via mailing list)
Hi Jonathan,

Using time is the only way I know how to demonstrate this:

FIRST TIME TOOK: 5.8 seconds

➜  ~  time curl -i -u demo: https://api.mydomain.com/v1/
HTTP/1.1 200 OK
Server: nginx
Date: Sat, 04 Jan 2014 04:07:50 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
Strict-Transport-Security: max-age=31556926
Cache-Control: no-cache, no-store
Access-Control-Max-Age: 300
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS

{"version":"v1"} curl -i -u demo: https://api.mydomain.com/v1/  0.54s
user
0.01s system 9% cpu 5.857 total

EXECUTED AGAIN, IMMEDIATELY AFTER. TOOK: 197ms

➜  ~  time curl -i -u demo: https://api.mydomain.com/v1/
HTTP/1.1 200 OK
Server: nginx
Date: Sat, 04 Jan 2014 04:07:54 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
Strict-Transport-Security: max-age=31556926
Cache-Control: no-cache, no-store
Access-Control-Max-Age: 300
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS

{"version":"v1"} curl -i -u demo: https://api.mydomain.com/v1/  0.05s
user
0.01s system 27% cpu 0.197 total

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,246001,246003#msg-246003
2974d09ac2541e892966b762aad84943?d=identicon&s=25 justink101 (Guest)
on 2014-01-06 21:35
(Received via mailing list)
Anybody have any further insight on this? Consistently slow DNS lookups
from
nginx, even though dig shows fast query times.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,246001,246070#msg-246070
34011bc56457235a2caa5ed1d4a29f3c?d=identicon&s=25 Jonathan Matthews (Guest)
on 2014-01-06 22:07
(Received via mailing list)
On 6 January 2014 20:34, justink101 <nginx-forum@nginx.us> wrote:
> Consistently slow DNS lookups from
> nginx

I *really* don't think you've demonstrated anything that points to
that conclusion. Do some tcpdump'ing. Show the data. Show your
working. ;-)

J
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.