Forum: NGINX proxied request hang when DNS server down

71f0c39de5f490522ce1893798ee6576?d=identicon&s=25 ywsample (Guest)
on 2014-08-19 07:43
(Received via mailing list)
http {
    resolver 127.0.0.1;
    resolver_timeout 1s;
    server {
        listen 8000;
        location /test {
            proxy_pass http://$arg_host:8080;
        }
    }
    server {
        listen 8080;
        .......
    }
}
ps: other configure is normal

I have recently discoverd that when DNS server down, the first proxy
request return 504 and than the follow proxy request may hang forever.
I use two curl simulate concurrent requests

I found than the first request timeout in 1 second and exit, also it
delete
the timeout timer. because another request waiting dns response, so
nginx
retry send dns query, but dns never response(because it down), it lead
to
the follow request hang and also no timer relate to it;

PS:base on nginx-1.7.4
F2c557716f4f3f7a94c76caeb242a015?d=identicon&s=25 SmallAnt (Guest)
on 2014-08-20 08:41
(Received via mailing list)
this module can help you !
HttpUpstreamJdomainModule,
http://wiki.nginx.org/HttpUpstreamJdomainModule.

It buffers the latest IPs of the host,even local dns server down, nginx
will work well.
71f0c39de5f490522ce1893798ee6576?d=identicon&s=25 ywsample (Guest)
on 2014-08-20 09:34
(Received via mailing list)
thanks

but I think nginx should not always pending requests and retry dns
forever。and inconsistent response to the first request and follow
requests
is also a problem. either all as a timeout processing, either all
waiting
dns response

may be nginx need change this behavior


2014-08-20 14:41 GMT+08:00 SmallAnt <unixant@gmail.com>:
2154be8b4430488454f0a067e09863b9?d=identicon&s=25 Ruslan Ermilov (Guest)
on 2014-08-20 09:59
(Received via mailing list)
Attachment: p (1 KB)
On Tue, Aug 19, 2014 at 01:43:06PM +0800, ywsample wrote:
>         listen 8080;
> the timeout timer. because another request waiting dns response, so nginx
> retry send dns query, but dns never response(because it down), it lead to
> the follow request hang and also no timer relate to it;
>
> PS???base on nginx-1.7.4

Please try the attached patch.  If you would like an attribution
in a commit log, please tell me your real name.
71f0c39de5f490522ce1893798ee6576?d=identicon&s=25 ywsample (Guest)
on 2014-08-22 11:56
(Received via mailing list)
hi Ruslan

>Please try the attached patch.  If you would like an attribution
>in a commit log, please tell me your real name.

thanks for the patch

I have a little idea, in ngx_resolver_timeout_handler function find the
next timeout request and add a timer if the time interval between two
requests exceeds the threshold, what do you think about it?

because this patch will appear premature timeout. For example if
resolver_timeout set to 5 seconds, the first request arrived at one
second,
another request arrived at five seconds. Then when the the first request
timeout, the second request immediately returned because of they were
pending for the same dns query.
but the desired result is nginx will try to resend the dns query and if
success the second request process normal otherwise timeout at ten
second.
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.