<div dir="ltr"><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">I do not know if your detailed explanation was aimed to me, or to the list in general, but I got all that already as far as I am concerned.<br></div><div class="gmail_extra"><br><div style="font-size:small;color:rgb(51,51,153)" class="gmail_default">To me, when an attempt is made to an upstream group where no peer can be selected, a 502 should be returned for that request, and no upstream having been selected, no $upstream_* variable should contain anything. An error message should be generated in the error log.<br></div><div style="font-size:small;color:rgb(51,51,153)" class="gmail_default">I fail to see the benefit of having the group name being considered as an upstream peer.... For cons, that name might get confused with a domain name, and the grammar of the $upstream_addr variable is complexified.<br></div><div style="font-size:small;color:rgb(51,51,153)" class="gmail_default">Not that, as stated before, the docs merely say the $upstream_addr should contains IP addresses and ports of peers, no mention of the upstream group name there.<br><br></div><div style="font-size:small;color:rgb(51,51,153)" class="gmail_default">Well, it seems your design decisions are made, and even though I see things differently, I understand what I did not get before.<br></div><div style="font-size:small;color:rgb(51,51,153)" class="gmail_default">Is my vision broke, ie some benefit I am failing to see about your implementation?<br></div><div style="font-size:small;color:rgb(51,51,153)" class="gmail_default"><br></div><div style="font-size:small;color:rgb(51,51,153)" class="gmail_default">Another linked question:<br></div><div style="font-size:small;color:rgb(51,51,153)" class="gmail_default">I got some cases in which $upstream_response_time was '-' for some peers (and not a numeric value like 0.000).<br></div><div style="font-size:small;color:rgb(51,51,153)" class="gmail_default">What is the meaning of that? Connection failed? I am not logging the $upstream_status variable, not $upstream_connect_time, thus have limited information.<br></div><div style="font-size:small;color:rgb(51,51,153)" class="gmail_default">Could that '-' appear anywhere in the list?<br></div><div><div class="gmail_signature" data-smartmail="gmail_signature"><font size="1"><span style="color:rgb(102,102,102)">---<br></span><b><span style="color:rgb(102,102,102)">B. R.</span></b><span style="color:rgb(102,102,102)"></span></font></div></div>
<br><div class="gmail_quote">On Thu, Apr 20, 2017 at 2:58 PM, Ruslan Ermilov <span dir="ltr"><<a href="mailto:ru@nginx.com" target="_blank">ru@nginx.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Wed, Apr 19, 2017 at 05:26:17PM +0200, B.R. via nginx wrote:<br>
> On Wed, Apr 19, 2017 at 10:51 AM, Ruslan Ermilov <<a href="mailto:ru@nginx.com">ru@nginx.com</a>> wrote:<br>
><br>
> > And what about the next request when all of servers are either "down"<br>
> > or "unavailable"?<br>
> ><br>
><br>
> To me, all the unavailable servers have been 'tried', ie their state has<br>
> been checked, as the docs<br>
</span>> <<a href="http://nginx.org/en/docs/http/ngx_http_upstream_module.html#upstream" rel="noreferrer" target="_blank">http://nginx.org/en/docs/<wbr>http/ngx_http_upstream_module.<wbr>html#upstream</a>> say<br>
<span class="">> every server of an upstream group will be checked.<br>
> Thus, they should all appear, along with the time it took for that lookup<br>
> to be made (usually 0.000 since no communication occurred and a simple<br>
> internal check has probably been made for the duration of the 'unavailable'<br>
> state).<br>
><br>
> No special value whatsoever, as none required, and the grammar of the 2<br>
> variables is stable.<br>
> If an explicit message about attempts against completely unavailable<br>
> upstream groups should be logged, it would be so in the error log.<br>
<br>
</span>Given the following config,<br>
<br>
upstream u {<br>
server <a href="http://127.0.0.1:8001" rel="noreferrer" target="_blank">127.0.0.1:8001</a>;<br>
server <a href="http://127.0.0.1:8002" rel="noreferrer" target="_blank">127.0.0.1:8002</a>;<br>
server <a href="http://127.0.0.1:8003" rel="noreferrer" target="_blank">127.0.0.1:8003</a>;<br>
}<br>
<br>
log_format u "upstream_addr={$upstream_<wbr>addr} upstream_status={$upstream_<wbr>status}";<br>
<br>
server {<br>
access_log logs/u.log u;<br>
<br>
listen 8000;<br>
<br>
location / {<br>
proxy_pass <a href="http://u" rel="noreferrer" target="_blank">http://u</a>;<br>
}<br>
}<br>
<br>
when none of the upstream servers are available, the first request will<br>
log<br>
<br>
upstream_addr={<a href="http://127.0.0.1:8001" rel="noreferrer" target="_blank">127.0.0.1:8001</a>, <a href="http://127.0.0.1:8002" rel="noreferrer" target="_blank">127.0.0.1:8002</a>, <a href="http://127.0.0.1:8003" rel="noreferrer" target="_blank">127.0.0.1:8003</a>} upstream_status={502, 502, 502}<br>
<br>
And the next request will log:<br>
<br>
upstream_addr={u} upstream_status={502}<br>
<br>
<br>
If you add the 4th "server <a href="http://127.0.0.1:8004" rel="noreferrer" target="_blank">127.0.0.1:8004</a> down" and start afresh, then the<br>
first request will end up with<br>
<br>
upstream_addr={<a href="http://127.0.0.1:8001" rel="noreferrer" target="_blank">127.0.0.1:8001</a>, <a href="http://127.0.0.1:8002" rel="noreferrer" target="_blank">127.0.0.1:8002</a>, <a href="http://127.0.0.1:8003" rel="noreferrer" target="_blank">127.0.0.1:8003</a>, u} upstream_status={502, 502, 502, 502}<br>
<br>
This is because the number of attempts equals the number of servers by<br>
default.<br>
<br>
<br>
Again, this is not a bug but a feature.<br>
<br>
The number of values in $upstream_* always corresponds to the number<br>
of attempts made to select a server. The last value can be a special<br>
value with the name of the upstream group when an attempt to select<br>
a peer has failed. This can happen on the 1st attempt, and then the<br>
only value will be the upstream group name.<br>
<div class="HOEnZb"><div class="h5">______________________________<wbr>_________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/<wbr>mailman/listinfo/nginx</a></div></div></blockquote></div><br></div></div>