- Edited
目前在ngx的文档里没找到upstream里的代理服务器组的单个代理服务器的超时的配置,
但是对应的在proxy_next_upstream里timeout又是默认的情况。想请教下有这个配置吗,
具体是在哪里呢?
目前在ngx的文档里没找到upstream里的代理服务器组的单个代理服务器的超时的配置,
但是对应的在proxy_next_upstream里timeout又是默认的情况。想请教下有这个配置吗,
具体是在哪里呢?
tweyseo
我没理解错的话,只有 proxy_connect_timeout 这种 location 级别的配置,没有办法针对 upstream 里面某个 server 配置超时时间
如果有用了 balancer_by_lua 的话,倒是可以每个 retry 都可以设置超时时间
https://github.com/openresty/lua-resty-core/blob/master/lib/ngx/balancer.md#set_timeouts
doujiang24 嗯 proxy*timeout 是通过location变相控制整个代理服务器组的 那怎么解释proxy_next_upstream的timeout是默认值的情况呢 这个timeout是依据什么来的呢
至于balancer 如果要对标upstream的话 需要自己额外做权重 断路器 等等不少东西
doujiang24 这里的描述:
The directive also defines what is considered an unsuccessful attempt of communication with a server. The cases of error, timeout and invalid_header are always considered unsuccessful attempts, even if they are not specified in the directive. The cases of http_500, http_502, http_503, http_504, and http_429 are considered unsuccessful attempts only if they are specified in the directive. The cases of http_403 and http_404 are never considered unsuccessful attempts.
tweyseo
哦,貌似我之前一直理解错了
proxy_next_upstream timeout;
这个实际上是针对每一次回上游的重试,不是针对某个 upstream server 的。
然后 nginx 里所有的网络都是有超时的,回上游也是一样的,proxy*timeout 也是有默认值的,所以默认项里可以有 timeout。
doujiang24 我理解是针对单个代理服务器的 而且我尝试过用proxy_*_timeout
来触发proxy_next_upstream timeout
但是实际上proxy_*_timeout
直接返回给客户端了 而没有继续去代理服务器组里再继续尝试了
tweyseo
应该不对的,nginx 对于重试的基本逻辑就是,回源请求之后,判断是否可以重试下一个 upstream server,这里面判断的条件就包括了 proxy_next_upstream
, proxy_next_upstream_out
, proxy_next_upstream_tries
等
感觉是你之前尝试的例子有点问题,可能是命中了其他条件,比如 POST 请求默认就是不会重试的