Proxy_read_timeout vs proxy_next_upstream_timeout

Hi

If you set read timeout 2 min and next upstream timeout 50 seconds, will
nginx break the current connection at 50 second or will it let the read
finish until 2min?

Thanks
Frank

Those directives works at very different levels.

proxy_next_upstream_timeout
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_next_upstream_timeout
allocates a time for nginx to find a proper upstream (configured with
proxy_next_upstream
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_next_upstream
).
By default, there is no limit, making nginx attempting every upstream
one
after the other until finding one healthy or running out of valid
upstreams, which could take a while (maybe even an infinite time with
health checks? Speculating here).

proxy_read_timeout
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_read_timeout
sets a timer ‘between two read operations’, say the docs, which is
closer
to your question.
Those are to be defined, but I suppose that when there is nothing more
to
read in the buffer awaiting backend response, and the response is not
complete, this timer kicks in and effectively close the connection,
returning an error.

​They are not working at the same level at all: there is no way to
mistake
one for the other.​

B. R.

Given this config:
proxy_next_upstream timeout;
proxy_next_upstream_timeout 50;
proxy_connect_timeout 10;
proxy_read_timeout 100;
If upstream has issues causing connect timeout, nginx will re-try 5
upstream servers until hitting 50, then fail.
If one upstream has issues causing read timeout, nginx will keep wait to
read, until 100, then timeout, then checks the
proxy_next_upstream_timeout
which is 50 and already passed, so nginx won’t retry next upstream.

I am trying to setup nginx to only retry on connect timeout, not read
timeout, will above work?

On Thu, Mar 31, 2016 at 6:54 PM, Frank L. [email protected] wrote:

Given this config:
proxy_next_upstream timeout;
proxy_next_upstream_timeout 50;
proxy_connect_timeout 10;
proxy_read_timeout 100;
If upstream has issues causing connect timeout, nginx will re-try 5
upstream servers until hitting 50, then fail.

http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_next_upstream_timeout
‘[…] hitting 50s […]’ (cf. http://nginx.org/en/docs/syntax.html)​

If one upstream has issues causing read timeout, nginx will keep wait to
read, until 100, then timeout,

http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_read_timeout
​nginx will wait for a maximum of 100s between two successful read
operations (or before the first one) and will fail if exceeded.

then checks the proxy_next_upstream_timeout which is 50 and already
passed, so nginx won’t retry next upstream.

I am trying to setup nginx to only retry on connect timeout, not read
timeout, will above work?


http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_next_upstream
The ‘timeout’ property regroups conneciton timeout and header read
timeout​.
Content read timeout is set by proxy_read_timeout
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_read_timeout
(default 60s)

B. R.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs